Open hasufell opened 3 years ago
It appears vim is treating it as an error when you try to jump beyond the file boundaries, e.g.:
nnoremap j 3j:echomsg "FOO"<cr>
Will not echo FOO
when you're on the last line and pressing j
.
As such, a workaround is this:
call submode#map('nav', 'n', 's', 'e', ':normal! 6j<cr>')
call submode#map('nav', 'n', 's', 'o', ':normal! 6k<cr>')
My guess is that this is happening because j
will "fail" if it cannot be moved. This is most noticeable in macros and mappings.
For example, if you do :let @q = "G3j:echo 'DONE'\<cr>"
and then do @q
, it will always (1) jump to the end of the file, (2) attempt to jump down three lines (this will fail because you're already at the end). Thus, the rest of the sequence is not executed because 3j
fails.
This is how vim has always behaved, but since you will most likely find this disagreeable, then you can certainly create a function and map to that function. Then use setcurpos()
and getcurpos()
and line('$')
appropriately,
Also! (Bonus) <cmd>
can be handy: nnoremap <leader>T <cmd>echo 'test'<cr>
I see you've also made acquaintance with romainl on freenode/#vim :) don't mind him.
Config is
I can enter the submode successfully and navigate. Once the cursor hits the end or beginning of the file (or rather: tries to move past it), the mappings stop working, but I'm still inside the submode.