157

I use the shortcut w to move the cursor one word right. Is there a shortcut to move a word left?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Suresh
  • 9,495
  • 14
  • 49
  • 63
  • Hello and welcome to StackOverflow! Note that this site is intended for questions directly related to programming problems; questions "how to *use* software X" would be better answered at superuser.com . I have voted to close this question; it would be automatically migrated there. – Piskvor left the building Dec 20 '10 at 11:08
  • 1
    Your post is still confusing, `w` does not move the cursor left. What are you trying to achieve? Moving the cursor (and if so in what direction) or moving words (again in what direction). – heijp06 Dec 20 '10 at 11:16
  • @Suresh: In future, try ask Vim-related questions on: http://unix.stackexchange.com/ If they are not Windows-specific, it won't be offtopic there, and you might find better answers then on SU, or at least faster – Goran Jovic Dec 20 '10 at 11:25
  • @Goran Jovic , I moved to SU for these kind of questions, thanks. – Suresh Dec 20 '10 at 11:27
  • @Suresh: Ok, I'm just saying there's a Unix.SE as well :) – Goran Jovic Dec 20 '10 at 11:28
  • 12
    Please. Stop scattering the vim community on all SE forums. We have 2707 questions tagged vim here on SO, 484 on SU, and now we have 31 question tagged vim on this new SE forum. BTW: http://unix.stackexchange.com/questions/107/what-are-the-best-general-purpose-programming-tools-to-complement-vim is completely off-topic there as SO is meant to be programming centred. (BTW I do use vim on windows every day.) – Luc Hermitte Dec 20 '10 at 14:18
  • @Luc: I have asked vim questions here myself and (as a child with a new toy) I find it very convenient to scroll through the new questions daily. On what site would you prefer vim specific questions being asked? – Lieven Keersmaekers Dec 21 '10 at 07:55
  • 4
    @Lieven : Consensus seems to be 'keep Vim questions on SO' since answers often includes vimscripts and Vim is a 'code oriented' tool. See question on Meta http://meta.stackexchange.com/q/25925/154445 – Xavier T. Dec 21 '10 at 10:21
  • I'd also vote for here (SO) (or even better: directly on vim mailing list) – Luc Hermitte Dec 21 '10 at 11:07

5 Answers5

317

Use b to move back one word.

Use w to move forward one word.

And here is a cheat sheet that might be useful for you:

Alt text

Source: Graphical vi-vim Cheat Sheet and Tutorial

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Wazery
  • 15,394
  • 19
  • 63
  • 95
26

It's b.

You can see other motions here:

Vim documentation: motion, 4. Word motions

Generally a Vim command consists of:

count action motion

Where:

count is number of times you want it to execute. The default is 1.

action is obviously an action: d for delete, c for change, default is empty, and it means simply move.

motion is the direction. You got that already.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Goran Jovic
  • 9,418
  • 3
  • 43
  • 75
  • I think what the OP is after is a shortcut to move a word to the right (or left, the title is confusing) not the cursor. – heijp06 Dec 20 '10 at 11:11
  • @Peter: the question says he uses `w` to move left, so apparently he's just trying to move the cursor – Nathan Fellman Dec 20 '10 at 12:23
  • @Nathan Fellman: The OP has edited the question. In it's present form it's clear that @Goran Jovic's answer is indeed what the OP was after. I will upvote the answer. – heijp06 Dec 20 '10 at 12:31
12

In addition to the b movement mentioned in the other answers, another movement which may be interesting is ge.

It brings you to the last letter of the word on the left. When b is considered as the opposite of w, ge can be considered as the opposite of e which brings you to the end of the current word.

Also note that all of those word-wise movement have a WORD-wise equivalent: W, B, E and gE which are "faster". For the difference between words and WORDS see: :h word.

statox
  • 2,827
  • 1
  • 21
  • 41
6

Yes, you can use "b" to backforward a word, and in advance, "2b" to move back two words.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jimmy Huang
  • 4,252
  • 2
  • 22
  • 22
5

You want to move left (back). b does it.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
khachik
  • 28,112
  • 9
  • 59
  • 94