1
- *change.txt* For Vim version 8.2. Last change: 2021 Mar 01
1
+ *change.txt* For Vim version 8.2. Last change: 2022 Mar 05
2
2
3
3
4
4
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -259,6 +259,9 @@ Or use "caw" (see |aw|).
259
259
line.
260
260
Adding [!] toggles 'autoindent' for the time this
261
261
command is executed.
262
+ This command is not supported in | Vim9 | script,
263
+ because it is too easily confused with a variable
264
+ name.
262
265
263
266
==============================================================================
264
267
3. Simple changes *simple-change*
@@ -775,17 +778,20 @@ matched pattern is deleted. The separator after {pattern} can also be left
775
778
out then. Example: >
776
779
:%s/TESTING
777
780
This deletes "TESTING" from all lines, but only one per line.
778
-
779
- For compatibility with Vi these two exceptions are allowed:
781
+ *E1270*
782
+ For compatibility with Vi these two exceptions are allowed in legacy script :
780
783
"\/{string} /" and "\?{string} ?" do the same as "//{string} /r".
781
784
"\&{string} &" does the same as "//{string} /".
782
- *pattern-delimiter* *E146*
783
- Instead of the '/' which surrounds the pattern and replacement string, you
784
- can use any other single-byte character, but not an alphanumeric character,
785
- '\', '"' or '|'. This is useful if you want to include a '/' in the search
786
- pattern or replacement string. Example: >
785
+ *pattern-delimiter* *E146* *E1241* *E1242*
786
+ Instead of the '/' which surrounds the pattern and replacement string, you can
787
+ use another single-byte character. This is useful if you want to include a
788
+ '/' in the search pattern or replacement string. Example: >
787
789
:s+/+//+
788
790
791
+ You can use most characters, but not an alphanumeric character, '\', '"' or
792
+ '|'. In Vim9 script you should not use '#' because it may be recognized as
793
+ the start of a comment.
794
+
789
795
For the definition of a pattern, see | pattern | . In Visual block mode, use
790
796
| /\%V | in the pattern to have the substitute work in the block only.
791
797
Otherwise it works on whole lines anyway.
@@ -940,7 +946,7 @@ Consider using a character like "@" or ":". There is no problem if the result
940
946
of the expression contains the separation character.
941
947
942
948
Examples: >
943
- :s@\n@\="\r" . expand("$HOME") . "\r"@
949
+ :s@\n@\="\r" .. expand("$HOME") . . "\r"@
944
950
This replaces an end-of-line with a new line containing the value of $HOME. >
945
951
946
952
s/E/\="\<Char-0x20ac>"/g
@@ -1042,6 +1048,10 @@ inside of strings can change! Also see 'softtabstop' option. >
1042
1048
cursor to the end of line (which is more logical,
1043
1049
but not Vi-compatible) use ":map Y y$".
1044
1050
1051
+ *zy*
1052
+ ["x]zy{motion} Yank {motion} text [into register x]. Only differs
1053
+ from `y ` when selecting a block of text, see | v_zy | .
1054
+
1045
1055
*v_y*
1046
1056
{Visual} ["x]y Yank the highlighted text [into register x] (for
1047
1057
{Visual} see | Visual-mode | ).
@@ -1050,6 +1060,12 @@ inside of strings can change! Also see 'softtabstop' option. >
1050
1060
{Visual} ["x]Y Yank the highlighted lines [into register x] (for
1051
1061
{Visual} see | Visual-mode | ).
1052
1062
1063
+ *v_zy*
1064
+ {Visual} ["x]zy Yank the highlighted text [into register x]. Trailing
1065
+ whitespace at the end of each line of a selected block
1066
+ won't be yanked. Especially useful in combination
1067
+ with `zp ` . (for {Visual} see | Visual-mode | )
1068
+
1053
1069
*:y* *:yank* *E850*
1054
1070
:[range] y[ank] [x] Yank [range] lines [into register x]. Yanking to the
1055
1071
"* or "+ registers is possible only when the
@@ -1060,7 +1076,7 @@ inside of strings can change! Also see 'softtabstop' option. >
1060
1076
in [range] (default: current line | cmdline-ranges | ),
1061
1077
[into register x].
1062
1078
1063
- *p* *put* *E353*
1079
+ *p* *put* *E353* *E1240 *
1064
1080
["x]p Put the text [from register x] after the cursor
1065
1081
[count] times.
1066
1082
@@ -1107,7 +1123,7 @@ inside of strings can change! Also see 'softtabstop' option. >
1107
1123
the command. You need to escape the '|' and '"'
1108
1124
characters to prevent them from terminating the
1109
1125
command. Example: >
1110
- :put ='path' . \",/test\"
1126
+ :put ='path' .. \",/test\"
1111
1127
< If there is no expression after '=', Vim uses the
1112
1128
previous expression. You can see it with ":dis =".
1113
1129
@@ -1126,6 +1142,12 @@ inside of strings can change! Also see 'softtabstop' option. >
1126
1142
Using the mouse only works when 'mouse' contains 'n'
1127
1143
or 'a'.
1128
1144
1145
+ ["x]zp or *zp* *zP*
1146
+ ["x]zP Like "p" and "P", except without adding trailing spaces
1147
+ when pasting a block. Thus the inserted text will not
1148
+ always be a rectangle. Especially useful in
1149
+ combination with | v_zy | .
1150
+
1129
1151
You can use these commands to copy text from one place to another. Do this
1130
1152
by first getting the text into a register with a yank, delete or change
1131
1153
command, then inserting the register contents with a put command. You can
@@ -1154,10 +1176,13 @@ register. With blockwise selection it also depends on the size of the block
1154
1176
and whether the corners are on an existing character. (Implementation detail:
1155
1177
it actually works by first putting the register after the selection and then
1156
1178
deleting the selection.)
1157
- The previously selected text is put in the unnamed register. If you want to
1158
- put the same text into a Visual selection several times you need to use
1179
+ With 'p' the previously selected text is put in the unnamed register. This is
1180
+ useful if you want to put that text somewhere else. But you cannot repeat the
1181
+ same change.
1182
+ With 'P' the unnamed register is not changed, you can repeat the same change.
1183
+ But the deleted text cannot be used. If you do need it you can use 'p' with
1159
1184
another register. E.g., yank the text to copy, Visually select the text to
1160
- replace and use "0p . You can repeat this as many times as you like, the
1185
+ replace and use "0p . You can repeat this as many times as you like, and the
1161
1186
unnamed register will be changed each time.
1162
1187
1163
1188
When you use a blockwise Visual mode command and yank only a single line into
@@ -1175,6 +1200,9 @@ this happen. However, if the width of the block is not a multiple of a <Tab>
1175
1200
width and the text after the inserted block contains <Tab> s, that text may be
1176
1201
misaligned.
1177
1202
1203
+ Use | zP | /| zp | to paste a blockwise yanked register without appending trailing
1204
+ spaces.
1205
+
1178
1206
Note that after a characterwise yank command, Vim leaves the cursor on the
1179
1207
first yanked character that is closest to the start of the buffer. This means
1180
1208
that "yl" doesn't move the cursor, but "yh" moves the cursor one character
@@ -1352,6 +1380,9 @@ The next three commands always work on whole lines.
1352
1380
1353
1381
*:t*
1354
1382
:t Synonym for copy.
1383
+ This command is not supported in | Vim9 | script,
1384
+ because it is too easily confused with a variable
1385
+ name.
1355
1386
1356
1387
:[range] m[ove] {address} *:m* *:mo* *:move* *E134*
1357
1388
Move the lines given by [range] to below the line
@@ -1649,7 +1680,8 @@ r Automatically insert the current comment leader after hitting
1649
1680
<Enter> in Insert mode.
1650
1681
*fo-o*
1651
1682
o Automatically insert the current comment leader after hitting 'o' or
1652
- 'O' in Normal mode.
1683
+ 'O' in Normal mode. In case comment is unwanted in a specific place
1684
+ use CTRL-U to quickly delete it. | i_CTRL-U |
1653
1685
*fo-q*
1654
1686
q Allow formatting of comments with "gq".
1655
1687
Note that formatting will not change blank lines or lines containing
0 commit comments