annotate runtime/doc/visual.txt @ 27966:80f398bfc19f v8.2.4508

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