How to select text in Vim (Visual mode)
In Normal mode, press v and move the cursor, with e to the end of a word or j down a line. The highlight follows. Then d deletes the selection, y copies it and c replaces it. V selects whole lines, Ctrl-v a rectangle.

The pineapple has run out, and the specials board still promises extra pineapple on the al pastor burrito. Those three words have to go, and you'd like to see exactly what's going before it goes. The cursor is on the space after burrito.
v starts Visual mode, and -- VISUAL -- shows at the bottom. From then on every move stretches a highlight from where you pressed v to the cursor. e jumps to the end of the word ahead, so each press takes in one more word. The next command you give acts on whatever is highlighted.
FRIDAY SPECIALSAl pastor burrito with extra pineapple 9.50Three churros in cinnamon sugar 3.00FRIDAY SPECIALSAl pastor burrito with extra pineapple 9.50Three churros in cinnamon sugar 3.00FRIDAY SPECIALSAl pastor burrito 9.50Three churros in cinnamon sugar 3.00pineapple, and d deletes all of itThe pineapple is off
Take the pineapple off the board, then swap the churros' topping for tonight's.
pineapple with e three times, then delete it with dspecials.txtThis editor needs a keyboard. Read on, and play it at your computer.
Select a word, a quoted string or a paragraph in one go
Any move works while you select, so w, b, j and $ all stretch the highlight. The selection always includes the character under the cursor, though. v then w reaches one letter into the next word, which is why e is the better way to stop at the end of one.
For the usual shapes there's a shortcut. After v, i means "inside" rather than Insert mode, and the letter after it names the shape. viw selects the word under the cursor from anywhere in it, vi" what's between the quotes around the cursor, and vip the paragraph, meaning the lines between two blank ones. Swap i for a to take the edges as well. va" includes the quotes, and vap includes the blank line after the paragraph.
Ready for the weekend
The board has a review to show off and a notice that is out of date. The cursor is in the review.
This editor needs a keyboard. Read on, and play it at your computer.
What you can do with a selection
Once the text is highlighted, the next key says what happens to it, and Visual mode ends. d deletes it, y copies it, and c deletes it and leaves you typing in its place. p swaps it for whatever you copied last. > and < indent and unindent every line the selection touches. U turns the letters into capitals, u into small letters, and ~ flips each one.
: opens the command line with :'<,'> already typed, which means "the lines the selection is on". Type a command after it, such as s/old/new/g, and it runs on those lines only. It always takes whole lines, even when you selected a single word.
A command on a selected word
The cursor is on extra. In Normal mode you press viw to select the word, then press :. Vim types '<,'> for you, and you add s/a/A/g and press ↵. What does the line say now?
Take in a word you missed, or reselect
You've highlighted chocolate dip and then notice the in in front of it should go too. Moving the cursor now only moves the end it's on, so b would shrink the selection from the right. Press o first. The cursor jumps to the start of the highlight, and b stretches it back over in. Press o again to return to the end you started from.
gv brings back the last selection, the same characters as before. Use it after a stray Esc, or after U when you want to do something more to the same words.
Stretch it the other way
The cursor is on the first letter of extra. In Normal mode you press v, then e twice, then o, then b, and finally U for capitals. What does the line say now?
Visual mode keys from memory
Each one starts in Normal mode unless it says otherwise. Type the keys you would press.
Select whole lines, a column or the whole file
v picks characters, which suits words and phrases. For whole lines, start with V instead. The highlight then covers every line the cursor passes over, wherever on the line it is, and Select lines has more on that. If you're halfway through a v selection, pressing V turns it into whole lines.
Ctrl-v (hold Ctrl, press v) selects a rectangle, the same columns on several lines. It's how you type the same thing at the start of every line, and Visual Block mode shows how. For everything in the file at once, ggVG does it, and Select all has the shortcuts that skip the selection.
| Keys | What it does |
|---|---|
| v | Start selecting characters, at the cursor. |
| v, then e / w / j / $ | Stretch the selection to wherever the move takes the cursor. |
| viw / vaw | Select the word under the cursor / the word and the space after it. |
| vi" / va" | Select inside the quotes / the quotes as well. |
| vi( / vit | Select inside the brackets / inside an HTML tag. |
| vip / vap | Select the paragraph / the paragraph and the blank line after it. |
| V | Select whole lines (select lines). |
| Ctrl-v | Select a rectangle (Visual Block mode). |
| o | Jump to the other end of the selection. |
| gv | Select the last selection again. |
| d / y / c | Delete it / copy it / delete it and start typing. |
| p | Replace it with what you copied last. |
| > / < | Indent / unindent the lines it touches. |
| U / u / ~ | Capitals / small letters / swap the case. |
| J | Join the selected lines into one. |
: | Run a command on the selected lines, from :'<,'>. |
| Esc | Stop selecting and change nothing. |