Move to end of current word in Vim

Tag: vim Author: snowcityfeng Date: 2012-09-02

Usually I use ea to append something to a word. However, this doesn't work if the cursor is already in the last position of the word. (ea will cause the cursor to move to the end of the next word.) Therefore, I'm interested to know whether there is any hotkey for moving to the end of current word even if the cursor is already in the last position of the word.


Best Answer

You can change the functionality of e if you desire. For example, you could put

nnoremap e he

in your ~/.vimrc. This maps e to he so that it works the way you want. However, you may find e useful and not want to make over it completely. You could use your <leader> key to add an alternate mapping.

nnoremap <leader>e he

So that you can use \e or ,e (depending on your mapleader setting) to achieve the desired effect. I tend to agree with the others that it's better to become used to vim's standard single keys though. In general, use maps for longer commands that you regularly use.

There's no builtin command like the one you're suggesting, but there is regex \> for the end of a word.


Thank you, Conner. Personally I think w/b are enough to move between words. And 99% of the time my 'e' is followed by an 'a'. Well, bad habit.