222

In Vim's normal mode:

  • e goes to the end of the next word
  • w goes to the beginning of the next word
  • b goes to the beginning of the previous word

How do you move the cursor to the end of the previous word?

ClosureCowboy
  • 20,825
  • 13
  • 57
  • 71

4 Answers4

306

Unfortunately it's not a single key... but ge is what you're looking for, I think.

Kenny Evitt
  • 9,291
  • 5
  • 65
  • 93
jkerian
  • 16,497
  • 3
  • 46
  • 59
  • 40
    For people like me wondering the difference between `ge` and `be`, it's that you can be in the middle of the word and you'll go to the end of the previous, while `be` you need to be on the first char of the initial word. – TankorSmash Dec 04 '13 at 04:06
  • 19
    And `gE` for the end of the previous `WORD`. :) – nitsas May 20 '15 at 15:34
  • 9
    seriously why isn't there a single key shortcut for this by default? this looks like something people would be using as frequently as `w`. am I missing something? (I know it can be mapped, just curious why) – Iman Akbari Apr 19 '17 at 08:08
  • 3
    While `be` is convenient, it's a combination of two commands, so you can't use it like: `d` `be`. Whereas `d` `ge` does work – Daniel Thompson Mar 15 '18 at 08:43
61

Try ge:

ge                      Backward to the end of word [count] |inclusive|.

                                                        *gE*
gE                      Backward to the end of WORD [count] |inclusive|.
Kenny Evitt
  • 9,291
  • 5
  • 65
  • 93
Stephan
  • 1,007
  • 7
  • 9
35

as seen on VIM manual (section 03.1), you can use ge to go to the end of previous word

Kenny Evitt
  • 9,291
  • 5
  • 65
  • 93
Eduardo Costa
  • 1,974
  • 1
  • 16
  • 22
4

You may also want to do these to go to the space preceding a word (one character after ge: (both are only 2 keys)

  1. FSpace will take you to the space after the previous word
  2. Bh will also do that, in most cases.

The exception is when you are at the beginning of a line, in which case

  1. k$ does something similar, in 3 keypresses
Community
  • 1
  • 1
Nathan majicvr.com
  • 950
  • 2
  • 11
  • 31