Vim Recipes ‣ Navigation ‣ Navigating Text Files
You're editing a text file such an essay or e-mail, and want to exploit its structure to navigate it efficiently.
In Normal mode you can use the following shortcuts:
| Key | Move To |
|---|---|
| { | Beginning of current paragraph |
| } | End of current paragraph |
| ( | Beginning of current sentence |
| ) | End of current sentence |
| w | Beginning of next word |
| b | Beginning of the previous word |
| e | End of the word |
The shortcuts above all rely on the fact that plain text is often very structured. A document consists of paragraphs separated by newlines. Paragraphs contain one or more sentences which begin with capital letters and end with periods. Sentences are collections of words which are separated by spaces.
After using one of these shortcuts you may want to return to where you were previously. This is particularly useful if you're writing one thing and are then reminded that you now have to change another: you use a shortcut to jump to the location of the change, then want to resume where you left of. You can use the g, (mnemonic: go back to where I paused (commas can be used to represent pauses…)) command. Each time you execute it you'll be taken back another step. To move in the other direction (towards more recent changes), use g;.
All of these shortcuts can be combined. So, to move to the end of the previous word you type be. You can also prefix them with numbers to indicate how many times they should be executed: 3b moves to the beginning of the 3rd previous word.