Fix behavior of e and w vim objects
This commit is contained in:
parent
3f4856bccd
commit
948a4e046d
|
@ -337,6 +337,7 @@ local translations = {
|
||||||
["next-char"] = translate.next_char,
|
["next-char"] = translate.next_char,
|
||||||
["previous-word-start"] = translate.previous_word_start,
|
["previous-word-start"] = translate.previous_word_start,
|
||||||
["next-word-end"] = translate.next_word_end,
|
["next-word-end"] = translate.next_word_end,
|
||||||
|
["next-word-begin"] = translate.next_word_begin,
|
||||||
["previous-block-start"] = translate.previous_block_start,
|
["previous-block-start"] = translate.previous_block_start,
|
||||||
["next-block-end"] = translate.next_block_end,
|
["next-block-end"] = translate.next_block_end,
|
||||||
["start-of-doc"] = translate.start_of_doc,
|
["start-of-doc"] = translate.start_of_doc,
|
||||||
|
|
|
@ -42,7 +42,7 @@ function translate.previous_word_start(doc, line, col)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function translate.next_word_end(doc, line, col)
|
function translate.up_to_word(doc, line, col)
|
||||||
local prev
|
local prev
|
||||||
local end_line, end_col = translate.end_of_doc(doc, line, col)
|
local end_line, end_col = translate.end_of_doc(doc, line, col)
|
||||||
while line < end_line or col < end_col do
|
while line < end_line or col < end_col do
|
||||||
|
@ -53,10 +53,22 @@ function translate.next_word_end(doc, line, col)
|
||||||
line, col = doc:position_offset(line, col, 1)
|
line, col = doc:position_offset(line, col, 1)
|
||||||
prev = char
|
prev = char
|
||||||
end
|
end
|
||||||
|
return line, col
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function translate.next_word_end(doc, line, col)
|
||||||
|
line, col = translate.up_to_word(doc, line, col)
|
||||||
return translate.end_of_word(doc, line, col)
|
return translate.end_of_word(doc, line, col)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function translate.next_word_begin(doc, line, col)
|
||||||
|
line, col = translate.end_of_word(doc, line, col)
|
||||||
|
return translate.up_to_word(doc, line, col)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function translate.start_of_word(doc, line, col)
|
function translate.start_of_word(doc, line, col)
|
||||||
while true do
|
while true do
|
||||||
local line2, col2 = doc:position_offset(line, col, -1)
|
local line2, col2 = doc:position_offset(line, col, -1)
|
||||||
|
|
|
@ -29,10 +29,11 @@ end
|
||||||
|
|
||||||
keymap.vim_verbs_obj = {'d', 'c'}
|
keymap.vim_verbs_obj = {'d', 'c'}
|
||||||
keymap.vim_verbs_imm = {'y', 'p', 'h', 'j', 'k', 'l', 'x', 'i', 'u'}
|
keymap.vim_verbs_imm = {'y', 'p', 'h', 'j', 'k', 'l', 'x', 'i', 'u'}
|
||||||
keymap.vim_objects = {'w', '$'}
|
keymap.vim_objects = {'e', 'w', '$'}
|
||||||
|
|
||||||
local vim_object_map = {
|
local vim_object_map = {
|
||||||
['w'] = 'next-word-end',
|
['e'] = 'next-word-end',
|
||||||
|
['w'] = 'next-word-begin',
|
||||||
['$'] = 'end-of-line',
|
['$'] = 'end-of-line',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +137,9 @@ function keymap.on_key_pressed(k)
|
||||||
keymap.vim_execute(keymap.command_verb, keymap.command_mult, stroke)
|
keymap.vim_execute(keymap.command_verb, keymap.command_mult, stroke)
|
||||||
keymap.reset_vim_command()
|
keymap.reset_vim_command()
|
||||||
return true
|
return true
|
||||||
|
elseif stroke == 'escape' then
|
||||||
|
keymap.reset_vim_command()
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
elseif mode == 'insert' then
|
elseif mode == 'insert' then
|
||||||
if stroke == 'escape' then
|
if stroke == 'escape' then
|
||||||
|
|
Loading…
Reference in New Issue