Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
57 lines (44 sloc) 2.4 KB
<h3 id="visually-selecting-text">Visually Selecting Text</h3>
<p>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 <abbr title="Graphical User
Interface">GUI</abbr> word processor using either the keyboard or, in
<i>Gvim</i>, the mouse.</p>
<p>To select text character by character change to <i>Visual</i> mode with
<tt>v</tt>, then <a href="#basic-navigation">move the cursor as
normal</a> using the <tt>h</tt>,<tt>j</tt>,<tt>k</tt>,<tt>l</tt> keys. For
example, to select the current character and the three that follow hit
<tt>v</tt>, then <tt>3l</tt>. To select the current paragraph:
<tt>v</tt>, then <tt>ap</tt>.</p>
<p>To select text by lines switch to <i>Visual Line</i> mode with
<tt>V</tt>, then move upwards and downwards with <tt>k</tt> and
<tt>j</tt> as normal. For example, to select the current line and the 2
following it hit <tt>V</tt>, then <tt>2j</tt>.</p>
<p>To select text in vertical blocks, or 'columns' to the rest of us, you use
<i>Visual Block</i> mode with
<kbd><kbd>&lt;Ctrl&gt;</kbd>-<kbd>v</kbd></kbd><span class=fn>Windows&reg; defines this
shortcut for pasting text, so
<kbd><kbd>&lt;Ctrl&gt;</kbd>-<kbd>q</kbd></kbd> exists as an alias.</span>. 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 <tt>&lt;Ctrl&gt;-v</tt>, move
one character to the right (<tt>l</tt>), then move down 20 lines with
<p>If you want to switch selection mode mid-selection hit
<tt>v</tt>, <tt>V</tt>, or
<tt>&lt;Ctrl&gt;-v</tt>, as appropriate.</p>
<p>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. ;-)</p>
<p>Having selected text, <tt>o</tt> can be used to toggle the cursor between
the beginning and end of the selection.</p>
<p>The point of selecting text is to operate on it. Here are some common
<li><a href="#copying-cutting-pasting">Copy/cut it</a>.</li>
<li>Format it, e.g. <kbd>gq</kbd>.</li>
<li><a href="#indenting-lines">Indent/unindent it</a>.</li>