/usr/share/doc/vim/html/visual.html is in vim-doc 2:8.0.1453-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | <HTML>
<HEAD>
<META HTTP-EQUIV="Content-type" content="text/html; charset=ISO-8859-1">
<TITLE>Vim documentation: visual</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>Vim documentation: visual</H1>
<A NAME="top"></A>
<A HREF="index.html">main help file</A>
<HR>
<PRE>
*<A NAME="visual.txt"></A><B>visual.txt</B>* For Vim version 8.0. Last change: 2017 Sep 02
VIM REFERENCE MANUAL by <A HREF="intro.html#Bram">Bram</A> <A HREF="intro.html#Moolenaar">Moolenaar</A>
<A HREF="#Visual">Visual</A> mode *<A NAME="Visual"></A><B>Visual</B>* *<A NAME="Visual-mode"></A><B>Visual-mode</B>* *<A NAME="visual-mode"></A><B>visual-mode</B>*
<A HREF="#Visual">Visual</A> mode is a flexible and <A HREF="starting.html#easy">easy</A> way to select a piece of text for an
<A HREF="motion.html#operator">operator</A>. It is the only way to select a block of text.
This is introduced in section |<A HREF="usr_04.html#04.4">04.4</A>| of the user manual.
1. Using <A HREF="#Visual">Visual</A> mode |<A HREF="#visual-use">visual-use</A>|
2. Starting and stopping <A HREF="#Visual">Visual</A> mode |<A HREF="#visual-start">visual-start</A>|
3. Changing the <A HREF="#Visual">Visual</A> area |<A HREF="#visual-change">visual-change</A>|
4. Operating on the <A HREF="#Visual">Visual</A> area |<A HREF="#visual-operators">visual-operators</A>|
5. Blockwise operators |<A HREF="#blockwise-operators">blockwise-operators</A>|
6. Repeating |<A HREF="#visual-repeat">visual-repeat</A>|
7. Examples |<A HREF="#visual-examples">visual-examples</A>|
8. Select mode |<A HREF="#Select-mode">Select-mode</A>|
{Vi has no <A HREF="#Visual">Visual</A> mode, the name "visual" is used for <A HREF="intro.html#Normal">Normal</A> mode, to
distinguish <A HREF="motion.html#it">it</A> from <A HREF="intro.html#Ex">Ex</A> mode}
{Since Vim 7.4.200 the |<A HREF="various.html#+visual">+visual</A>| feature is always included}
==============================================================================
1. Using <A HREF="#Visual">Visual</A> mode *<A NAME="visual-use"></A><B>visual-use</B>*
Using <A HREF="#Visual">Visual</A> mode consists of three parts:
1. <A HREF="motion.html#Mark">Mark</A> the start of the text with "<A HREF="#v">v</A>", "<A HREF="#V">V</A>" or <A HREF="#CTRL-V">CTRL-V</A>.
The character under the cursor will be used <A HREF="motion.html#as">as</A> the start.
2. Move to the end of the text.
The text from the start of the <A HREF="#Visual">Visual</A> mode up to and including the
character under the cursor is highlighted.
3. Type an <A HREF="motion.html#operator">operator</A> command.
The highlighted characters will be operated upon.
The <A HREF="options.html#'highlight'">'highlight'</A> option can be used to set the display mode to use for
highlighting in <A HREF="#Visual">Visual</A> mode.
The <A HREF="options.html#'virtualedit'">'virtualedit'</A> option can be used to allow positioning the cursor to
positions where there is no actual character.
The highlighted text normally includes the character under the cursor.
However, when the <A HREF="options.html#'selection'">'selection'</A> option is set to "<A HREF="motion.html#exclusive">exclusive</A>" and the cursor is
after the <A HREF="#Visual">Visual</A> area, the character under the cursor is not included.
With "<A HREF="#v">v</A>" the text before the start position and after the end position will
not be highlighted. However, all <A HREF="change.html#uppercase">uppercase</A> and non-alpha operators, except
"<A HREF="change.html#~">~</A>" and "<A HREF="undo.html#U">U</A>", will work on whole lines anyway. See the <A HREF="eval.html#list">list</A> of operators
below.
*<A NAME="visual-block"></A><B>visual-block</B>*
With <A HREF="#CTRL-V">CTRL-V</A> (blockwise <A HREF="#Visual">Visual</A> mode) the highlighted text will be a rectangle
between start position and the cursor. However, some operators work on whole
lines anyway (see the <A HREF="eval.html#list">list</A> below). The change and substitute operators will
delete the highlighted text and then start insertion at the top left
position.
==============================================================================
2. Starting and stopping <A HREF="#Visual">Visual</A> mode *<A NAME="visual-start"></A><B>visual-start</B>*
*<A NAME="v"></A><B>v</B>* *<A NAME="characterwise-visual"></A><B>characterwise-visual</B>*
[count]v Start <A HREF="#Visual">Visual</A> mode per character.
With <A HREF="intro.html#[count]">[count]</A> select the same number of characters or
lines <A HREF="motion.html#as">as</A> used for the last <A HREF="#Visual">Visual</A> operation, but at
the current cursor position, multiplied by <A HREF="intro.html#[count]">[count]</A>.
When the previous <A HREF="#Visual">Visual</A> operation was on a block both
the width and height of the block are multiplied by
<A HREF="intro.html#[count]">[count]</A>.
When there was no previous <A HREF="#Visual">Visual</A> operation <A HREF="intro.html#[count]">[count]</A>
characters are selected. This is like moving the
cursor right N * <A HREF="intro.html#[count]">[count]</A> characters. One <A HREF="various.html#less">less</A> when
<A HREF="options.html#'selection'">'selection'</A> is not "<A HREF="motion.html#exclusive">exclusive</A>".
*<A NAME="V"></A><B>V</B>* *<A NAME="linewise-visual"></A><B>linewise-visual</B>*
[count]V Start <A HREF="#Visual">Visual</A> mode <A HREF="motion.html#linewise">linewise</A>.
With <A HREF="intro.html#[count]">[count]</A> select the same number of lines <A HREF="motion.html#as">as</A> used
for the last <A HREF="#Visual">Visual</A> operation, but at the current
cursor position, multiplied by <A HREF="intro.html#[count]">[count]</A>. When there
was no previous <A HREF="#Visual">Visual</A> operation <A HREF="intro.html#[count]">[count]</A> lines are
selected.
*<A NAME="CTRL-V"></A><B>CTRL-V</B>* *<A NAME="blockwise-visual"></A><B>blockwise-visual</B>*
[count]CTRL-V Start <A HREF="#Visual">Visual</A> mode blockwise. Note: Under Windows
<A HREF="#CTRL-V">CTRL-V</A> could be mapped to paste text, <A HREF="motion.html#it">it</A> doesn't work
to start <A HREF="#Visual">Visual</A> mode then, see |<A HREF="gui_w32.html#CTRL-V-alternative">CTRL-V-alternative</A>|.
<A HREF="intro.html#[count]">[count]</A> is used <A HREF="motion.html#as">as</A> with `v` above.
If you use <A HREF="intro.html#<Esc>"><Esc></A>, click the left mouse button or use any command that
does a jump to another buffer while in <A HREF="#Visual">Visual</A> mode, the highlighting stops
and no text is affected. Also when you hit "<A HREF="#v">v</A>" in <A HREF="motion.html#characterwise">characterwise</A> <A HREF="#Visual">Visual</A> mode,
"<A HREF="#CTRL-V">CTRL-V</A>" in blockwise <A HREF="#Visual">Visual</A> mode or "<A HREF="#V">V</A>" in <A HREF="motion.html#linewise">linewise</A> <A HREF="#Visual">Visual</A> mode. If you hit
<A HREF="starting.html#CTRL-Z">CTRL-Z</A> the highlighting stops and the editor is suspended or a new shell is
started |<A HREF="starting.html#CTRL-Z">CTRL-Z</A>|.
new mode after typing: *<A NAME="v_v"></A><B>v_v</B>* *<A NAME="v_CTRL-V"></A><B>v_CTRL-V</B>* *<A NAME="v_V"></A><B>v_V</B>*
<B><FONT COLOR="PURPLE">old mode "v" "CTRL-V" "V" </FONT></B>
<A HREF="intro.html#Normal">Normal</A> <A HREF="#Visual">Visual</A> blockwise <A HREF="#Visual">Visual</A> <A HREF="motion.html#linewise">linewise</A> <A HREF="#Visual">Visual</A>
<A HREF="#Visual">Visual</A> <A HREF="intro.html#Normal">Normal</A> blockwise <A HREF="#Visual">Visual</A> <A HREF="motion.html#linewise">linewise</A> <A HREF="#Visual">Visual</A>
blockwise <A HREF="#Visual">Visual</A> <A HREF="#Visual">Visual</A> <A HREF="intro.html#Normal">Normal</A> <A HREF="motion.html#linewise">linewise</A> <A HREF="#Visual">Visual</A>
<A HREF="motion.html#linewise">linewise</A> <A HREF="#Visual">Visual</A> <A HREF="#Visual">Visual</A> blockwise <A HREF="#Visual">Visual</A> <A HREF="intro.html#Normal">Normal</A>
*<A NAME="gv"></A><B>gv</B>* *<A NAME="v_gv"></A><B>v_gv</B>* *<A NAME="reselect-Visual"></A><B>reselect-Visual</B>*
<A HREF="#gv">gv</A> Start <A HREF="#Visual">Visual</A> mode with the same area <A HREF="motion.html#as">as</A> the previous
area and the same mode.
In <A HREF="#Visual">Visual</A> mode the current and the previous <A HREF="#Visual">Visual</A>
area are exchanged.
After using "<A HREF="change.html#p">p</A>" or "<A HREF="change.html#P">P</A>" in <A HREF="#Visual">Visual</A> mode the text that
was put will be selected.
*<A NAME="gn"></A><B>gn</B>* *<A NAME="v_gn"></A><B>v_gn</B>*
<A HREF="#gn">gn</A> Search forward for the last used search <A HREF="pattern.html#pattern">pattern</A>, like
with `n`, and start <A HREF="#Visual">Visual</A> mode to select the match.
If the cursor is on the match, visually selects <A HREF="motion.html#it">it</A>.
If an <A HREF="motion.html#operator">operator</A> is pending, operates on the match.
E.g., "<A HREF="motion.html#dgn">dgn</A>" deletes the text of the next match.
If <A HREF="#Visual">Visual</A> mode is active, extends the selection
until the end of the next match.
*<A NAME="gN"></A><B>gN</B>* *<A NAME="v_gN"></A><B>v_gN</B>*
<A HREF="#gN">gN</A> Like |<A HREF="#gn">gn</A>| but searches backward, like with `N`.
*<A NAME="<LeftMouse>"></A><B><LeftMouse></B>*
<A HREF="#<LeftMouse>"><LeftMouse></A> Set the current cursor position. If <A HREF="#Visual">Visual</A> mode is
active <A HREF="motion.html#it">it</A> is stopped. Only when <A HREF="options.html#'mouse'">'mouse'</A> option is
contains '<A HREF="pattern.html#n">n</A>' or '<A HREF="insert.html#a">a</A>'. If the position is within <A HREF="options.html#'so'">'so'</A>
lines from the last line on the screen the text is
scrolled up. If the position is within <A HREF="options.html#'so'">'so'</A> lines from
the first line on the screen the text is scrolled
down.
*<A NAME="<RightMouse>"></A><B><RightMouse></B>*
<A HREF="#<RightMouse>"><RightMouse></A> Start <A HREF="#Visual">Visual</A> mode if <A HREF="motion.html#it">it</A> is not active. The text from
the cursor position to the position of the click is
highlighted. If <A HREF="#Visual">Visual</A> mode was already active move
the start or end of the highlighted text, which ever
is closest, to the position of the click. Only when
<A HREF="options.html#'mouse'">'mouse'</A> option contains '<A HREF="pattern.html#n">n</A>' or '<A HREF="insert.html#a">a</A>'.
Note: when <A HREF="options.html#'mousemodel'">'mousemodel'</A> is set to "popup",
<A HREF="term.html#<S-LeftMouse>"><S-LeftMouse></A> has to be used instead of <A HREF="#<RightMouse>"><RightMouse></A>.
*<A NAME="<LeftRelease>"></A><B><LeftRelease></B>*
<A HREF="#<LeftRelease>"><LeftRelease></A> This works like a <A HREF="#<LeftMouse>"><LeftMouse></A>, if <A HREF="motion.html#it">it</A> is not at
the same position <A HREF="motion.html#as">as</A> <A HREF="#<LeftMouse>"><LeftMouse></A>. In an older version
of xterm you won't see the selected area until the
button is released, unless there is access to the
display where the xterm is running (via the DISPLAY
environment variable or the <A HREF="gui_x11.html#-display">-display</A> argument). Only
when <A HREF="options.html#'mouse'">'mouse'</A> option contains '<A HREF="pattern.html#n">n</A>' or '<A HREF="insert.html#a">a</A>'.
If <A HREF="#Visual">Visual</A> mode is not active and the "<A HREF="#v">v</A>", "<A HREF="#V">V</A>" or <A HREF="#CTRL-V">CTRL-V</A> is preceded with a
<A HREF="intro.html#count">count</A>, the size of the previously highlighted area is used for a start. You
can then move the end of the highlighted area and give an <A HREF="motion.html#operator">operator</A>. The type
of the old area is used (character, line or blockwise).
- Linewise <A HREF="#Visual">Visual</A> mode: The number of lines is multiplied with the <A HREF="intro.html#count">count</A>.
- Blockwise <A HREF="#Visual">Visual</A> mode: The number of lines and columns is multiplied with
the <A HREF="intro.html#count">count</A>.
- <A HREF="intro.html#Normal">Normal</A> <A HREF="#Visual">Visual</A> mode within one line: The number of characters is multiplied
with the <A HREF="intro.html#count">count</A>.
- <A HREF="intro.html#Normal">Normal</A> <A HREF="#Visual">Visual</A> mode with several lines: The number of lines is multiplied
with the <A HREF="intro.html#count">count</A>, in the last line the same number of characters is used <A HREF="motion.html#as">as</A>
in the last line in the previously highlighted area.
The start of the text is the Cursor position. If the "<A HREF="motion.html#$">$</A>" command was used <A HREF="motion.html#as">as</A>
one of the last commands to extend the highlighted text, the area will be
extended to the rightmost column of the longest line.
If you want to highlight exactly the same area <A HREF="motion.html#as">as</A> the last time, you can use
"gv" |<A HREF="#gv">gv</A>| |<A HREF="#v_gv">v_gv</A>|.
*<A NAME="v_<Esc>"></A><B>v_<Esc></B>*
<A HREF="intro.html#<Esc>"><Esc></A> In <A HREF="#Visual">Visual</A> mode: Stop <A HREF="#Visual">Visual</A> mode.
*<A NAME="v_CTRL-C"></A><B>v_CTRL-C</B>*
<A HREF="pattern.html#CTRL-C">CTRL-C</A> In <A HREF="#Visual">Visual</A> mode: Stop <A HREF="#Visual">Visual</A> mode. When insert mode is
pending (the mode message shows
"<A HREF="starting.html#--">--</A> (insert) VISUAL --"), <A HREF="motion.html#it">it</A> is also stopped.
==============================================================================
3. Changing the <A HREF="#Visual">Visual</A> area *<A NAME="visual-change"></A><B>visual-change</B>*
*<A NAME="v_o"></A><B>v_o</B>*
<A HREF="insert.html#o">o</A> Go to Other end of highlighted text: The current
cursor position becomes the start of the highlighted
text and the cursor is moved to the other end of the
highlighted text. The highlighted area remains the
same.
*<A NAME="v_O"></A><B>v_O</B>*
<A HREF="insert.html#O">O</A> Go to Other end of highlighted text. This is like
"<A HREF="insert.html#o">o</A>", but in <A HREF="#Visual">Visual</A> block mode the cursor moves to the
other corner in the same line. When the corner is at
a character that occupies more than one position on
the screen (e.g., a <Tab>), the highlighted text may
change.
*<A NAME="v_$"></A><B>v_$</B>*
When the "<A HREF="motion.html#$">$</A>" command is used with blockwise <A HREF="#Visual">Visual</A> mode, the right end of the
highlighted text will be determined by the longest highlighted line. This
stops when a motion command is used that does not move straight up or down.
For moving the end of the block many commands can be used, but you cannot
use <A HREF="intro.html#Ex">Ex</A> commands, commands that make changes or <A HREF="editing.html#abandon">abandon</A> the file. Commands
(starting with) "<A HREF="repeat.html#.">.</A>", "<A HREF="change.html#&">&</A>", <A HREF="editing.html#CTRL-^">CTRL-^</A>, "Z", <A HREF="tagsrch.html#CTRL-]">CTRL-]</A>, <A HREF="tagsrch.html#CTRL-T">CTRL-T</A>, <A HREF="undo.html#CTRL-R">CTRL-R</A>, <A HREF="motion.html#CTRL-I">CTRL-I</A>
and <A HREF="motion.html#CTRL-O">CTRL-O</A> cause a beep and <A HREF="#Visual">Visual</A> mode continues.
When switching to another <A HREF="windows.html#window">window</A> on the same buffer, the cursor position in
that <A HREF="windows.html#window">window</A> is adjusted, so that the same <A HREF="#Visual">Visual</A> area is still selected. This
is especially useful to <A HREF="starting.html#view">view</A> the start of the <A HREF="#Visual">Visual</A> area in one <A HREF="windows.html#window">window</A>, and
the end in another. You can then use <A HREF="#<RightMouse>"><RightMouse></A> (or <A HREF="term.html#<S-LeftMouse>"><S-LeftMouse></A> when
<A HREF="options.html#'mousemodel'">'mousemodel'</A> is "popup") to drag either end of the <A HREF="#Visual">Visual</A> area.
==============================================================================
4. Operating on the <A HREF="#Visual">Visual</A> area *<A NAME="visual-operators"></A><B>visual-operators</B>*
The operators that can be used are:
~ switch <A HREF="change.html#case">case</A> |<A HREF="change.html#v_~">v_~</A>|
d delete |<A HREF="change.html#v_d">v_d</A>|
c change (4) |<A HREF="change.html#v_c">v_c</A>|
y <A HREF="change.html#yank">yank</A> |<A HREF="change.html#v_y">v_y</A>|
> <A HREF="intro.html#shift">shift</A> right (4) |<A HREF="change.html#v_>">v_></A>|
< <A HREF="intro.html#shift">shift</A> left (4) |<A HREF="change.html#v_<">v_<</A>|
! <A HREF="change.html#filter">filter</A> through external command (1) |<A HREF="change.html#v_!">v_!</A>|
= <A HREF="change.html#filter">filter</A> through <A HREF="options.html#'equalprg'">'equalprg'</A> option command (1) |<A HREF="change.html#v_=">v_=</A>|
gq format lines to <A HREF="options.html#'textwidth'">'textwidth'</A> length (1) |<A HREF="change.html#v_gq">v_gq</A>|
The <A HREF="index.html#objects">objects</A> that can be used are:
aw a <A HREF="motion.html#word">word</A> (with white space) |<A HREF="motion.html#v_aw">v_aw</A>|
iw inner <A HREF="motion.html#word">word</A> |<A HREF="motion.html#v_iw">v_iw</A>|
aW a <A HREF="motion.html#WORD">WORD</A> (with white space) |<A HREF="motion.html#v_aW">v_aW</A>|
iW inner <A HREF="motion.html#WORD">WORD</A> |<A HREF="motion.html#v_iW">v_iW</A>|
as a <A HREF="motion.html#sentence">sentence</A> (with white space) |<A HREF="motion.html#v_as">v_as</A>|
is inner <A HREF="motion.html#sentence">sentence</A> |<A HREF="motion.html#v_is">v_is</A>|
ap a <A HREF="motion.html#paragraph">paragraph</A> (with white space) |<A HREF="motion.html#v_ap">v_ap</A>|
ip inner <A HREF="motion.html#paragraph">paragraph</A> |<A HREF="motion.html#v_ip">v_ip</A>|
ab a () block (with parenthesis) |<A HREF="motion.html#v_ab">v_ab</A>|
ib inner () block |<A HREF="motion.html#v_ib">v_ib</A>|
aB a <A HREF="intro.html#{}">{}</A> block (with braces) |<A HREF="motion.html#v_aB">v_aB</A>|
iB inner <A HREF="intro.html#{}">{}</A> block |<A HREF="motion.html#v_iB">v_iB</A>|
at a <tag> </tag> block (with <A HREF="tagsrch.html#tags">tags</A>) |<A HREF="motion.html#v_at">v_at</A>|
it inner <tag> </tag> block |<A HREF="motion.html#v_it">v_it</A>|
a< a <A HREF="intro.html#<>"><></A> block (with <A HREF="intro.html#<>"><></A>) |<A HREF="motion.html#v_a<">v_a<</A>|
i< inner <A HREF="intro.html#<>"><></A> block |<A HREF="motion.html#v_i<">v_i<</A>|
a[ a <A HREF="motion.html#[]">[]</A> block (with <A HREF="motion.html#[]">[]</A>) |<A HREF="motion.html#v_a[">v_a[</A>|
i[ inner <A HREF="motion.html#[]">[]</A> block |<A HREF="motion.html#v_i[">v_i[</A>|
a" a double quoted <A HREF="eval.html#string">string</A> (with <A HREF="quotes.html#quotes">quotes</A>) |<A HREF="motion.html#v_aquote">v_aquote</A>|
i" inner double quoted <A HREF="eval.html#string">string</A> |<A HREF="motion.html#v_iquote">v_iquote</A>|
a' a single quoted <A HREF="eval.html#string">string</A> (with <A HREF="quotes.html#quotes">quotes</A>) |<A HREF="motion.html#v_a'">v_a'</A>|
i' inner simple quoted <A HREF="eval.html#string">string</A> |<A HREF="motion.html#v_i'">v_i'</A>|
a` a <A HREF="eval.html#string">string</A> in backticks (with backticks) |<A HREF="motion.html#v_a`">v_a`</A>|
i` inner <A HREF="eval.html#string">string</A> in backticks |<A HREF="motion.html#v_i`">v_i`</A>|
Additionally the following commands can be used:
: start <A HREF="intro.html#Ex">Ex</A> command for highlighted lines (1) |<A HREF="cmdline.html#v_:">v_:</A>|
r change (4) |<A HREF="change.html#v_r">v_r</A>|
s change |<A HREF="change.html#v_s">v_s</A>|
C change (2)(4) |<A HREF="change.html#v_C">v_C</A>|
S change (2) |<A HREF="change.html#v_S">v_S</A>|
R change (2) |<A HREF="change.html#v_R">v_R</A>|
x delete |<A HREF="change.html#v_x">v_x</A>|
D delete (3) |<A HREF="change.html#v_D">v_D</A>|
X delete (2) |<A HREF="change.html#v_X">v_X</A>|
Y <A HREF="change.html#yank">yank</A> (2) |<A HREF="change.html#v_Y">v_Y</A>|
p put |<A HREF="change.html#v_p">v_p</A>|
J join (1) |<A HREF="change.html#v_J">v_J</A>|
U make <A HREF="change.html#uppercase">uppercase</A> |<A HREF="change.html#v_U">v_U</A>|
u make <A HREF="change.html#lowercase">lowercase</A> |<A HREF="change.html#v_u">v_u</A>|
^] find <A HREF="tagsrch.html#tag">tag</A> |<A HREF="tagsrch.html#v_CTRL-]">v_CTRL-]</A>|
I block insert |<A HREF="#v_b_I">v_b_I</A>|
A block append |<A HREF="#v_b_A">v_b_A</A>|
(1): Always whole lines, see |<A HREF="#:visual_example">:visual_example</A>|.
(2): Whole lines when not using <A HREF="#CTRL-V">CTRL-V</A>.
(3): Whole lines when not using <A HREF="#CTRL-V">CTRL-V</A>, delete until the end of the line when
using <A HREF="#CTRL-V">CTRL-V</A>.
(4): When using <A HREF="#CTRL-V">CTRL-V</A> operates on the block only.
Note that the "<A HREF="map.html#:vmap">:vmap</A>" command can be used to specifically map keys in <A HREF="#Visual">Visual</A>
mode. For example, if you would like the "<A HREF="pattern.html#/">/</A>" command not to extend the <A HREF="#Visual">Visual</A>
area, but instead take the highlighted text and search for that:
<B> :vmap / y/<C-R>"<CR></B>
(In the <> <A HREF="intro.html#notation">notation</A> |<A HREF="intro.html#<>"><></A>|, when typing <A HREF="motion.html#it">it</A> you should type <A HREF="motion.html#it">it</A> literally; you
need to remove the '<A HREF="motion.html#B">B</A>' and '<A HREF="change.html#<"><</A>' flags from <A HREF="options.html#'cpoptions'">'cpoptions'</A>.)
If you want to give a <A HREF="sponsor.html#register">register</A> name using the """ command, <A HREF="diff.html#do">do</A> this just before
typing the <A HREF="motion.html#operator">operator</A> character: "v{move-around}"xd".
If you want to give a <A HREF="intro.html#count">count</A> to the command, <A HREF="diff.html#do">do</A> this just before typing the
<A HREF="motion.html#operator">operator</A> character: "v{move-around}3>" (move lines 3 indents to the right).
*<A NAME="{move-around}"></A><B>{move-around}</B>*
The <A HREF="#{move-around}">{move-around}</A> is any sequence of <A HREF="intro.html#movement">movement</A> commands. Note the difference
with <A HREF="intro.html#{motion}">{motion}</A>, which is only ONE <A HREF="intro.html#movement">movement</A> command.
Another way to operate on the <A HREF="#Visual">Visual</A> area is using the |<A HREF="pattern.html#/\%V">/\%V</A>| item in a
<A HREF="pattern.html#pattern">pattern</A>. For example, to replace all '<A HREF="motion.html#(">(</A>' in the <A HREF="#Visual">Visual</A> area with '<A HREF="pattern.html##">#</A>':
<B> :'<,'>s/\%V(/#/g</B>
Note that the "'<,'>" will appear automatically when you press "<A HREF="cmdline.html#:">:</A>" in <A HREF="#Visual">Visual</A>
mode.
==============================================================================
5. Blockwise operators *<A NAME="blockwise-operators"></A><B>blockwise-operators</B>*
{not available when compiled without the |<A HREF="various.html#+visualextra">+visualextra</A>| feature}
Reminder: Use <A HREF="options.html#'virtualedit'">'virtualedit'</A> to be able to select blocks that start or end
after the end of a line or halfway a <A HREF="intro.html#tab">tab</A>.
Visual-block <A HREF="insert.html#Insert">Insert</A> *<A NAME="v_b_I"></A><B>v_b_I</B>*
With a blockwise selection, I{string}<ESC> will insert {string} at the start
of block on every line of the block, provided that the line extends into the
block. Thus lines that are short will remain unmodified. TABs are split to
retain visual columns. Works only for adding text to a line, not for
deletions. See |<A HREF="#v_b_I_example">v_b_I_example</A>|.
Visual-block Append *<A NAME="v_b_A"></A><B>v_b_A</B>*
With a blockwise selection, A{string}<ESC> will append {string} to the end of
block on every line of the block. There is some differing behavior where the
block RHS is not straight, due to different line lengths:
1. Block was created with <C-v>$
In this <A HREF="change.html#case">case</A> the <A HREF="eval.html#string">string</A> is appended to the end of each line.
2. Block was created with <C-v>{move-around}
In this <A HREF="change.html#case">case</A> the <A HREF="eval.html#string">string</A> is appended to the end of the block on each line,
and <A HREF="pattern.html#whitespace">whitespace</A> is inserted to pad to the end-of-block column.
See |<A HREF="#v_b_A_example">v_b_A_example</A>|.
Note: "<A HREF="insert.html#I">I</A>" and "<A HREF="insert.html#A">A</A>" behave differently for lines that don't extend into the
selected block. This was done intentionally, so that you can <A HREF="diff.html#do">do</A> <A HREF="motion.html#it">it</A> the way
you want.
Works only for adding text to a line, not for deletions.
Visual-block change *<A NAME="v_b_c"></A><B>v_b_c</B>*
All selected text in the block will be replaced by the same text <A HREF="eval.html#string">string</A>. When
using "<A HREF="change.html#c">c</A>" the selected text is deleted and <A HREF="insert.html#Insert">Insert</A> mode started. You can then
enter text (without a line break). When you hit <A HREF="intro.html#<Esc>"><Esc></A>, the same <A HREF="eval.html#string">string</A> is
inserted in all previously selected lines.
Visual-block Change *<A NAME="v_b_C"></A><B>v_b_C</B>*
Like using "<A HREF="change.html#c">c</A>", but the selection is extended until the end of the line for
all lines.
*<A NAME="v_b_<"></A><B>v_b_<</B>*
Visual-block Shift *<A NAME="v_b_>"></A><B>v_b_></B>*
The block is shifted by <A HREF="options.html#'shiftwidth'">'shiftwidth'</A>. The RHS of the block is irrelevant. The
LHS of the block determines the point from which to apply a right <A HREF="intro.html#shift">shift</A>, and
padding includes TABs optimally according to <A HREF="options.html#'ts'">'ts'</A> and <A HREF="options.html#'et'">'et'</A>. The LHS of the
block determines the point upto which to <A HREF="intro.html#shift">shift</A> left.
See |<A HREF="#v_b_>_example">v_b_>_example</A>|.
See |<A HREF="#v_b_<_example">v_b_<_example</A>|.
Visual-block <A HREF="insert.html#Replace">Replace</A> *<A NAME="v_b_r"></A><B>v_b_r</B>*
Every screen char in the highlighted region is replaced with the same char, ie
TABs are split and the virtual <A HREF="pattern.html#whitespace">whitespace</A> is replaced, maintaining screen
layout.
See |<A HREF="#v_b_r_example">v_b_r_example</A>|.
==============================================================================
6. Repeating *<A NAME="visual-repeat"></A><B>visual-repeat</B>*
When <A HREF="repeat.html#repeating">repeating</A> a <A HREF="#Visual">Visual</A> mode <A HREF="motion.html#operator">operator</A>, the <A HREF="motion.html#operator">operator</A> will be applied to the
same amount of text <A HREF="motion.html#as">as</A> the last time:
- Linewise <A HREF="#Visual">Visual</A> mode: The same number of lines.
- Blockwise <A HREF="#Visual">Visual</A> mode: The same number of lines and columns.
- <A HREF="intro.html#Normal">Normal</A> <A HREF="#Visual">Visual</A> mode within one line: The same number of characters.
- <A HREF="intro.html#Normal">Normal</A> <A HREF="#Visual">Visual</A> mode with several lines: The same number of lines, in the
last line the same number of characters <A HREF="motion.html#as">as</A> in the last line the last time.
The start of the text is the Cursor position. If the "<A HREF="motion.html#$">$</A>" command was used <A HREF="motion.html#as">as</A>
one of the last commands to extend the highlighted text, the <A HREF="repeat.html#repeating">repeating</A> will
be applied up to the rightmost column of the longest line.
==============================================================================
7. Examples *<A NAME="visual-examples"></A><B>visual-examples</B>*
*<A NAME=":visual_example"></A><B>:visual_example</B>*
Currently the "<A HREF="cmdline.html#:">:</A>" command works on whole lines only. When you select part of
a line, doing something like ":!date" will replace the whole line. If you
want only part of the line to be replaced you will have to make a <A HREF="map.html#mapping">mapping</A> for
<A HREF="motion.html#it">it</A>. In a future release "<A HREF="cmdline.html#:">:</A>" may work on partial lines.
Here is an example, to replace the selected text with the output of "date":
<B> :vmap _a <Esc>`>a<CR><Esc>`<i<CR><Esc>!!date<CR>kJJ</B>
(In the <> <A HREF="intro.html#notation">notation</A> |<A HREF="intro.html#<>"><></A>|, when typing <A HREF="motion.html#it">it</A> you should type <A HREF="motion.html#it">it</A> literally; you
need to remove the '<A HREF="motion.html#B">B</A>' and '<A HREF="change.html#<"><</A>' flags from <A HREF="options.html#'cpoptions'">'cpoptions'</A>)
What this does is:
<A HREF="intro.html#<Esc>"><Esc></A> stop <A HREF="#Visual">Visual</A> mode
<A HREF="motion.html#`>">`></A> go to the end of the <A HREF="#Visual">Visual</A> area
a<CR><Esc> break the line after the <A HREF="#Visual">Visual</A> area
<A HREF="motion.html#`<">`<</A> jump to the start of the <A HREF="#Visual">Visual</A> area
i<CR><Esc> break the line before the <A HREF="#Visual">Visual</A> area
!!date<CR> <A HREF="change.html#filter">filter</A> the <A HREF="#Visual">Visual</A> text through date
kJJ Join the lines back together
*<A NAME="visual-search"></A><B>visual-search</B>*
Here is an idea for a <A HREF="map.html#mapping">mapping</A> that makes <A HREF="motion.html#it">it</A> possible to <A HREF="diff.html#do">do</A> a search for the
selected text:
<B> :vmap X y/<C-R>"<CR></B>
(In the <> <A HREF="intro.html#notation">notation</A> |<A HREF="intro.html#<>"><></A>|, when typing <A HREF="motion.html#it">it</A> you should type <A HREF="motion.html#it">it</A> literally; you
need to remove the '<A HREF="motion.html#B">B</A>' and '<A HREF="change.html#<"><</A>' flags from <A HREF="options.html#'cpoptions'">'cpoptions'</A>)
Note that special characters (like '<A HREF="repeat.html#.">.</A>' and '*') will cause problems.
Visual-block Examples *<A NAME="blockwise-examples"></A><B>blockwise-examples</B>*
With the following text, I will indicate the commands to produce the block and
the results below. In all cases, the cursor begins on the '<A HREF="insert.html#a">a</A>' in the first
line of the test text.
The following <A HREF="options.html#modeline">modeline</A> settings are assumed ":ts=8:sw=4:".
It will be helpful to
<A HREF="options.html#:set">:set</A> <A HREF="options.html#'hls'">hls</A>
/<TAB>
where <TAB> is a real TAB. This helps visualise the operations.
The test text is:
abcdefghijklmnopqrstuvwxyz
abc defghijklmnopqrstuvwxyz
abcdef ghi jklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
1. fo<C-v>3jISTRING<ESC> *<A NAME="v_b_I_example"></A><B>v_b_I_example</B>*
abcdefghijklmnSTRINGopqrstuvwxyz
abc STRING defghijklmnopqrstuvwxyz
abcdef ghi STRING jklmnopqrstuvwxyz
abcdefghijklmnSTRINGopqrstuvwxyz
2. fo<C-v>3j$ASTRING<ESC> *<A NAME="v_b_A_example"></A><B>v_b_A_example</B>*
abcdefghijklmnopqrstuvwxyzSTRING
abc defghijklmnopqrstuvwxyzSTRING
abcdef ghi jklmnopqrstuvwxyzSTRING
abcdefghijklmnopqrstuvwxyzSTRING
3. fo<C-v>3j3l<.. *<A NAME="v_b_<_example"></A><B>v_b_<_example</B>*
abcdefghijklmnopqrstuvwxyz
abc defghijklmnopqrstuvwxyz
abcdef ghi jklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyz
4. fo<C-v>3j>.. *<A NAME="v_b_>_example"></A><B>v_b_>_example</B>*
abcdefghijklmn opqrstuvwxyz
abc defghijklmnopqrstuvwxyz
abcdef ghi jklmnopqrstuvwxyz
abcdefghijklmn opqrstuvwxyz
5. fo<C-v>5l3jrX *<A NAME="v_b_r_example"></A><B>v_b_r_example</B>*
abcdefghijklmnXXXXXXuvwxyz
abc XXXXXXhijklmnopqrstuvwxyz
abcdef ghi XXXXXX jklmnopqrstuvwxyz
abcdefghijklmnXXXXXXuvwxyz
==============================================================================
8. <A HREF="#Select">Select</A> mode *<A NAME="Select"></A><B>Select</B>* *<A NAME="Select-mode"></A><B>Select-mode</B>*
<A HREF="#Select">Select</A> mode looks like <A HREF="#Visual">Visual</A> mode, but the commands accepted are quite
different. This resembles the selection mode in Microsoft Windows.
When the <A HREF="options.html#'showmode'">'showmode'</A> option is set, "<A HREF="starting.html#--">--</A> SELECT --" is shown in the last line.
Entering <A HREF="#Select">Select</A> mode:
- Using the mouse to select an area, and <A HREF="options.html#'selectmode'">'selectmode'</A> contains "mouse".
<A HREF="options.html#'mouse'">'mouse'</A> must also contain a flag for the current mode.
- Using a non-printable <A HREF="intro.html#movement">movement</A> command, with the Shift key pressed, and
<A HREF="options.html#'selectmode'">'selectmode'</A> contains "key". For example: <A HREF="motion.html#<S-Left>"><S-Left></A> and <A HREF="term.html#<S-End>"><S-End></A>. <A HREF="options.html#'keymodel'">'keymodel'</A>
must also contain "startsel".
- Using "<A HREF="#v">v</A>", "<A HREF="#V">V</A>" or <A HREF="#CTRL-V">CTRL-V</A> command, and <A HREF="options.html#'selectmode'">'selectmode'</A> contains "cmd".
- Using "<A HREF="#gh">gh</A>", "<A HREF="#gH">gH</A>" or "<A HREF="#g_CTRL-H">g_CTRL-H</A>" command in <A HREF="intro.html#Normal">Normal</A> mode.
- From <A HREF="#Visual">Visual</A> mode, press <A HREF="editing.html#CTRL-G">CTRL-G</A>. *<A NAME="v_CTRL-G"></A><B>v_CTRL-G</B>*
Commands in <A HREF="#Select">Select</A> mode:
- Printable characters, <A HREF="motion.html#<NL>"><NL></A> and <A HREF="motion.html#<CR>"><CR></A> cause the selection to be deleted, and
Vim enters <A HREF="insert.html#Insert">Insert</A> mode. The typed character is inserted.
- Non-printable <A HREF="intro.html#movement">movement</A> commands, with the Shift key pressed, extend the
selection. <A HREF="options.html#'keymodel'">'keymodel'</A> must include "startsel".
- Non-printable <A HREF="intro.html#movement">movement</A> commands, with the Shift key NOT pressed, stop <A HREF="#Select">Select</A>
mode. <A HREF="options.html#'keymodel'">'keymodel'</A> must include "stopsel".
- ESC stops <A HREF="#Select">Select</A> mode.
- <A HREF="motion.html#CTRL-O">CTRL-O</A> switches to <A HREF="#Visual">Visual</A> mode for the duration of one command. *<A NAME="v_CTRL-O"></A><B>v_CTRL-O</B>*
- <A HREF="editing.html#CTRL-G">CTRL-G</A> switches to <A HREF="#Visual">Visual</A> mode.
Otherwise, typed characters are handled <A HREF="motion.html#as">as</A> in <A HREF="#Visual">Visual</A> mode.
When using an <A HREF="motion.html#operator">operator</A> in <A HREF="#Select">Select</A> mode, and the selection is <A HREF="motion.html#linewise">linewise</A>, the
selected lines are operated upon, but like in <A HREF="motion.html#characterwise">characterwise</A> selection. For
example, when a whole line is deleted, <A HREF="motion.html#it">it</A> can later be pasted halfway a line.
Mappings and <A HREF="gui.html#menus">menus</A> in <A HREF="#Select">Select</A> mode. *<A NAME="Select-mode-mapping"></A><B>Select-mode-mapping</B>*
When mappings and <A HREF="gui.html#menus">menus</A> are defined with the |<A HREF="map.html#:vmap">:vmap</A>| or |<A HREF="gui.html#:vmenu">:vmenu</A>| command they
work both in <A HREF="#Visual">Visual</A> mode and in <A HREF="#Select">Select</A> mode. When these are used in <A HREF="#Select">Select</A>
mode Vim automatically switches to <A HREF="#Visual">Visual</A> mode, so that the same behavior <A HREF="motion.html#as">as</A>
in <A HREF="#Visual">Visual</A> mode is effective. If you don't want this use |<A HREF="map.html#:xmap">:xmap</A>| or |<A HREF="map.html#:smap">:smap</A>|.
Users will expect printable characters to replace the selected area.
Therefore avoid <A HREF="map.html#mapping">mapping</A> printable characters in <A HREF="#Select">Select</A> mode. Or use
|<A HREF="map.html#:sunmap">:sunmap</A>| after |<A HREF="map.html#:map">:map</A>| and |<A HREF="map.html#:vmap">:vmap</A>| to remove <A HREF="motion.html#it">it</A> for <A HREF="#Select">Select</A> mode.
After the <A HREF="map.html#mapping">mapping</A> or menu finishes, the selection is enabled again and <A HREF="#Select">Select</A>
mode entered, unless the selected area was deleted, another buffer became
the current one or the <A HREF="windows.html#window">window</A> layout was changed.
When a character was typed that causes the selection to be deleted and <A HREF="insert.html#Insert">Insert</A>
mode started, <A HREF="insert.html#Insert">Insert</A> mode mappings are applied to this character. This may
cause some confusion, because <A HREF="motion.html#it">it</A> means <A HREF="insert.html#Insert">Insert</A> mode mappings apply to a
character typed in <A HREF="#Select">Select</A> mode. Language mappings apply <A HREF="motion.html#as">as</A> well.
*<A NAME="gV"></A><B>gV</B>* *<A NAME="v_gV"></A><B>v_gV</B>*
<A HREF="#gV">gV</A> Avoid the automatic reselection of the <A HREF="#Visual">Visual</A> area
after a <A HREF="#Select">Select</A> mode <A HREF="map.html#mapping">mapping</A> or menu has finished.
Put this just before the end of the <A HREF="map.html#mapping">mapping</A> or menu.
At least <A HREF="motion.html#it">it</A> should be after any operations on the
selection.
*<A NAME="gh"></A><B>gh</B>*
<A HREF="#gh">gh</A> Start <A HREF="#Select">Select</A> mode, <A HREF="motion.html#characterwise">characterwise</A>. This is like "<A HREF="#v">v</A>",
but starts <A HREF="#Select">Select</A> mode instead of <A HREF="#Visual">Visual</A> mode.
Mnemonic: "get highlighted".
*<A NAME="gH"></A><B>gH</B>*
<A HREF="#gH">gH</A> Start <A HREF="#Select">Select</A> mode, <A HREF="motion.html#linewise">linewise</A>. This is like "<A HREF="#V">V</A>",
but starts <A HREF="#Select">Select</A> mode instead of <A HREF="#Visual">Visual</A> mode.
Mnemonic: "get Highlighted".
*<A NAME="g_CTRL-H"></A><B>g_CTRL-H</B>*
<A HREF="index.html#g">g</A> <A HREF="motion.html#CTRL-H">CTRL-H</A> Start <A HREF="#Select">Select</A> mode, blockwise. This is like <A HREF="#CTRL-V">CTRL-V</A>,
but starts <A HREF="#Select">Select</A> mode instead of <A HREF="#Visual">Visual</A> mode.
Mnemonic: "get Highlighted".
<A HREF="#top">top</A> - <A HREF="index.html">main help file</A>
</PRE>
</BODY>
</HTML>
|