Coming from non-modal editors, I still get confused with e, w, b in Vim.

One feature I like about non-modal editors is jumping words by simply combining Ctrl with arrow. So I thought I just create a Vim equivalent using Ctrl+h instead of b and Ctrl+l instead of e. Both in visual and normal mode. It looks like there are no other shortcuts interfering by default.

Does anyone know how to change .vimrc to map the keys accordingly?

closed as off-topic by Antony, DJMcMayhem, Sato Katsura, grochmal, EvergreenTree Jul 30 '16 at 14:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers." – Antony, DJMcMayhem, Sato Katsura, grochmal, EvergreenTree
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    It's working here, can you try with nnoremap and vnoremap and have a look at vi.stackexchange.com/a/7723/1821 and vi.stackexchange.com/a/2004/1821 – nobe4 Jul 22 '16 at 10:22
  • yep, I tried and it is working in both normal/visual modes.. can you tell us how exactly it is going wrong? like what happens when you type them? did you source ~/.vimrc after making changes? you can close and open vim as well for changes to take effect – Sundeep Jul 22 '16 at 10:23
  • I did reload Vim. I also did source ~/.vimrc. When I hit ctrl+h or ctrl+l nothing happens, the cursor stays where it is. I just checked :map and it shows me this: <C-H> <C-W>h and <C-L> <C-W>l and more stuff. @spasic No, I don't need the arrow keys.. – Rotareti Jul 22 '16 at 10:32
  • can you try :nmap <C-h> b from within vim and see if it works? I suspect you'll have to debug using links given by @nobe4 – Sundeep Jul 22 '16 at 10:37
  • @spasic that works. I'll try a restart ;) brb. Edit: restart did not help.. – Rotareti Jul 22 '16 at 10:40

Found a solution. This works fine:

nnoremap <C-h> b
nnoremap <C-l> e
vnoremap <C-h> b
vnoremap <C-l> e
  • 1
    Unless you're remapping a <plug> map (often found in plugins) always use nnoremap and vnoremap. Maps (that are not *nore*) are recursive into other maps, and that becomes a mess very quickly. – grochmal Jul 22 '16 at 20:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.