I have the following in my init.vim (neovim):
nnoremap i k nnoremap j h nnoremap k j xnoremap i k xnoremap j h xnoremap k j nnoremap h i nnoremap H I
I find this arrow key-like configuration much more comfortable, and aside from a few edge cases where plugins define special windows and don't expose movement remapping, it didn't seem to break anything...
...until I tried to use
viw, i.e. select inner word from normal mode. What happens now is that after pressing
vi, vim either waits
timeoutlen for a key sequence and then moves the cursor up a line, or cancels the sequence if
w is pressed and executes the normal
w action, i.e. move to the beginning of the next word. Pressing
i again while in visual mode starts another sequence countdown, so upward movement is also a bit jerky.
I'm pretty sure I understand why the sequence countdown happens, namely that
i is ambiguous between "move up a line" and "start of a text object," but I don't understand why
w cancels the text object sequence instead of completing it. Note that this is true for all text objects, e.g.
(. Is this expected behavior?
Ideally, I would like behavior like the following:
- After entering visual mode, wait
timeoutlenfor a sequence to begin
- If a sequence is begun, wait indefinitely for it to be completed or canceled with an invalid key press
- If no sequence is begun or (2) completes, thereafter ignore sequences until visual mode is exited
Intuitively, this might not be scriptable, but any help would be appreciated. As a fallback, I would at least like for
iw to work as expected in visual mode.
EDIT: @d-ben-knoble's answer doesn't quite get to the why of this, so I'm leaving the question unanswered in case anyone wants to take a whack at what exactly is going on.
That said, you'll all be proud I'm sure to know that there's officially an
hjkl branch in my dot files repo now. It's actually not as bad as I remember. I think it was overwhelming when I was first learning vim and everything was new, so I used arrows for a while, then realized having to move my hand to transition in and out of insert mode sucked and ended up in the situation described above. I guess
hjkl is the last step of the indoctrination process :)