Vim Recipes ‣ Basics ‣ Visually Selecting Text
You want to interactively select some text by drawing a box around it, thus enabling you to perform a command that affects it. In other words, you want to select a text like you would in a GUI word processor using either the keyboard or, in Gvim, the mouse.
To select text character by character change to Visual mode with v, then move the cursor as normal using the h,j,k,l keys. For example, to select the current character and the three that follow hit v, then 3l. To select the current paragraph: v, then ap.
To select text by lines switch to Visual Line mode with V, then move upwards and downwards with k and j as normal. For example, to select the current line and the 2 following it hit V, then 2j.
To select text in vertical blocks, or 'columns' to the rest of us, you use Visual Block mode with <Ctrl>-vWindows® defines this shortcut for pasting text, so <Ctrl>-q exists as an alias.. For example, if you wanted to select the first two characters of the current line and the 20 following, you'd position your cursor on the first character of the first line you're interested in, hit <Ctrl>-v, move one character to the right (l), then move down 20 lines with 20j.
If you want to switch selection mode mid-selection hit v, V, or <Ctrl>-v, as appropriate.
As you get used to Vim's movement command, you'll have less of a need for the various visual modes. Regardless, they can still be convenient when you're making complex selections or aren't really sure what you're doing. ;-)
Having selected text, o can be used to toggle the cursor between the beginning and end of the selection.
The point of selecting text is to operate on it. Here are some common actions: