Mercurial > vim
comparison runtime/doc/change.txt @ 1621:82b5078be2dd
updated for version 7.2a
author | vimboss |
---|---|
date | Tue, 24 Jun 2008 21:56:24 +0000 |
parents | afad99b3612c |
children | 0b796e045c42 |
comparison
equal
deleted
inserted
replaced
1620:73fe8baea242 | 1621:82b5078be2dd |
---|---|
1 *change.txt* For Vim version 7.1. Last change: 2007 Jan 07 | 1 *change.txt* For Vim version 7.2a. Last change: 2008 Jun 22 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
227 further characters (just like Insert mode). In Replace mode, the backspace | 227 further characters (just like Insert mode). In Replace mode, the backspace |
228 key restores the original text (if there was any). (See section "Insert and | 228 key restores the original text (if there was any). (See section "Insert and |
229 Replace mode" |mode-ins-repl|). | 229 Replace mode" |mode-ins-repl|). |
230 | 230 |
231 *cw* *cW* | 231 *cw* *cW* |
232 Special case: "cw" and "cW" work the same as "ce" and "cE" if the cursor is | 232 Special case: When the cursor is in a word, "cw" and "cW" do not include the |
233 on a non-blank. This is because Vim interprets "cw" as change-word, and a | 233 white space after a word, they only change up to the end of the word. This is |
234 word does not include the following white space. {Vi: "cw" when on a blank | 234 because Vim interprets "cw" as change-word, and a word does not include the |
235 followed by other blanks changes only the first blank; this is probably a | 235 following white space. |
236 bug, because "dw" deletes all the blanks; use the 'w' flag in 'cpoptions' to | 236 {Vi: "cw" when on a blank followed by other blanks changes only the first |
237 make it work like Vi anyway} | 237 blank; this is probably a bug, because "dw" deletes all the blanks; use the |
238 'w' flag in 'cpoptions' to make it work like Vi anyway} | |
238 | 239 |
239 If you prefer "cw" to include the space after a word, use this mapping: > | 240 If you prefer "cw" to include the space after a word, use this mapping: > |
240 :map cw dwi | 241 :map cw dwi |
241 < | 242 Or use "caw" (see |aw|). |
243 | |
242 *:c* *:ch* *:change* | 244 *:c* *:ch* *:change* |
243 :{range}c[hange][!] Replace lines of text with some different text. | 245 :{range}c[hange][!] Replace lines of text with some different text. |
244 Type a line containing only "." to stop replacing. | 246 Type a line containing only "." to stop replacing. |
245 Without {range}, this command changes only the current | 247 Without {range}, this command changes only the current |
246 line. | 248 line. |
343 |Visual-mode|). {not in Vi} | 345 |Visual-mode|). {not in Vi} |
344 | 346 |
345 g?g? *g?g?* *g??* | 347 g?g? *g?g?* *g??* |
346 g?? Rot13 encode current line. {not in Vi}. | 348 g?? Rot13 encode current line. {not in Vi}. |
347 | 349 |
350 To turn one line into title caps, make every first letter of a word | |
351 uppercase: > | |
352 :s/\v<(.)(\w*)/\u\1\L\2/g | |
353 | |
348 | 354 |
349 Adding and subtracting ~ | 355 Adding and subtracting ~ |
350 *CTRL-A* | 356 *CTRL-A* |
351 CTRL-A Add [count] to the number or alphabetic character at | 357 CTRL-A Add [count] to the number or alphabetic character at |
352 or after the cursor. {not in Vi} | 358 or after the cursor. {not in Vi} |
472 | 478 |
473 4.1 Filter commands *filter* | 479 4.1 Filter commands *filter* |
474 | 480 |
475 A filter is a program that accepts text at standard input, changes it in some | 481 A filter is a program that accepts text at standard input, changes it in some |
476 way, and sends it to standard output. You can use the commands below to send | 482 way, and sends it to standard output. You can use the commands below to send |
477 some text through a filter, so that it is replace by the filter output. | 483 some text through a filter, so that it is replaced by the filter output. |
478 Examples of filters are "sort", which sorts lines alphabetically, and | 484 Examples of filters are "sort", which sorts lines alphabetically, and |
479 "indent", which formats C program files (you need a version of indent that | 485 "indent", which formats C program files (you need a version of indent that |
480 works like a filter; not all versions do). The 'shell' option specifies the | 486 works like a filter; not all versions do). The 'shell' option specifies the |
481 shell Vim uses to execute the filter command (See also the 'shelltype' | 487 shell Vim uses to execute the filter command (See also the 'shelltype' |
482 option). You can repeat filter commands with ".". Vim does not recognize a | 488 option). You can repeat filter commands with ".". Vim does not recognize a |
659 :& | 665 :& |
660 < The last command will replace "blue" with "red". | 666 < The last command will replace "blue" with "red". |
661 {not in Vi} | 667 {not in Vi} |
662 | 668 |
663 Note that there is no flag to change the "magicness" of the pattern. A | 669 Note that there is no flag to change the "magicness" of the pattern. A |
664 different command is used instead. The reason is that the flags can only be | 670 different command is used instead, or you can use |/\v| and friends. The |
665 found by skipping the pattern, and in order to skip the pattern the | 671 reason is that the flags can only be found by skipping the pattern, and in |
666 "magicness" must be known. Catch 22! | 672 order to skip the pattern the "magicness" must be known. Catch 22! |
667 | 673 |
668 If the {pattern} for the substitute command is empty, the command uses the | 674 If the {pattern} for the substitute command is empty, the command uses the |
669 pattern from the last substitute or ":global" command. With the [r] flag, the | 675 pattern from the last substitute or ":global" command. With the [r] flag, the |
670 command uses the pattern from the last substitute, ":global", or search | 676 command uses the pattern from the last substitute, ":global", or search |
671 command. | 677 command. |
684 can use any other single-byte character, but not an alphanumeric character, | 690 can use any other single-byte character, but not an alphanumeric character, |
685 '\', '"' or '|'. This is useful if you want to include a '/' in the search | 691 '\', '"' or '|'. This is useful if you want to include a '/' in the search |
686 pattern or replacement string. Example: > | 692 pattern or replacement string. Example: > |
687 :s+/+//+ | 693 :s+/+//+ |
688 | 694 |
689 For the definition of a pattern, see |pattern|. | 695 For the definition of a pattern, see |pattern|. In Visual block mode, use |
696 |/\%V| in the pattern to have the substitute work in the block only. | |
697 Otherwise it works on whole lines anyway. | |
690 | 698 |
691 *sub-replace-special* *:s\=* | 699 *sub-replace-special* *:s\=* |
692 When the {string} starts with "\=" it is evaluated as an expression, see | 700 When the {string} starts with "\=" it is evaluated as an expression, see |
693 |sub-replace-expression|. You can use that for any special characters. | 701 |sub-replace-expression|. You can use that for any special characters. |
694 Otherwise these characters in {string} have a special meaning: | 702 Otherwise these characters in {string} have a special meaning: |
1126 | 1134 |
1127 9. Last search pattern register "/ *quote_/* *quote/* | 1135 9. Last search pattern register "/ *quote_/* *quote/* |
1128 Contains the most recent search-pattern. This is used for "n" and 'hlsearch'. | 1136 Contains the most recent search-pattern. This is used for "n" and 'hlsearch'. |
1129 It is writable with ":let", you can change it to have 'hlsearch' highlight | 1137 It is writable with ":let", you can change it to have 'hlsearch' highlight |
1130 other matches without actually searching. You can't yank or delete into this | 1138 other matches without actually searching. You can't yank or delete into this |
1131 register. {not in Vi} | 1139 register. The search direction is available in |v:searchforward|. |
1140 Note that the valued is restored when returning from a function | |
1141 |function-search-undo|. | |
1142 {not in Vi} | |
1132 | 1143 |
1133 *@/* | 1144 *@/* |
1134 You can write to a register with a ":let" command |:let-@|. Example: > | 1145 You can write to a register with a ":let" command |:let-@|. Example: > |
1135 :let @/ = "the" | 1146 :let @/ = "the" |
1136 | 1147 |
1251 There is no command in Vim to right justify text. You can do it with | 1262 There is no command in Vim to right justify text. You can do it with |
1252 an external command, like "par" (e.g.: "!}par" to format until the end of the | 1263 an external command, like "par" (e.g.: "!}par" to format until the end of the |
1253 paragraph) or set 'formatprg' to "par". | 1264 paragraph) or set 'formatprg' to "par". |
1254 | 1265 |
1255 *format-comments* | 1266 *format-comments* |
1256 Vim can format comments in a special way. Vim recognizes a comment by a | 1267 An overview of comment formatting is in section |30.6| of the user manual. |
1257 specific string at the start of the line (ignoring white space). Three types | 1268 |
1258 of comments can be used: | 1269 Vim can automatically insert and format comments in a special way. Vim |
1270 recognizes a comment by a specific string at the start of the line (ignoring | |
1271 white space). Three types of comments can be used: | |
1259 | 1272 |
1260 - A comment string that repeats at the start of each line. An example is the | 1273 - A comment string that repeats at the start of each line. An example is the |
1261 type of comment used in shell scripts, starting with "#". | 1274 type of comment used in shell scripts, starting with "#". |
1262 - A comment string that occurs only in the first line, not in the following | 1275 - A comment string that occurs only in the first line, not in the following |
1263 lines. An example is this list with dashes. | 1276 lines. An example is this list with dashes. |
1264 - Three-piece comments that have a start string, an end string, and optional | 1277 - Three-piece comments that have a start string, an end string, and optional |
1265 lines in between. The strings for the start, middle and end are different. | 1278 lines in between. The strings for the start, middle and end are different. |
1266 An example is the C-style comment: | 1279 An example is the C style comment: |
1267 /* | 1280 /* |
1268 * this is a C comment | 1281 * this is a C comment |
1269 */ | 1282 */ |
1270 | 1283 |
1271 The 'comments' option is a comma-separated list of parts. Each part defines a | 1284 The 'comments' option is a comma-separated list of parts. Each part defines a |
1287 | 1300 |
1288 m Middle of a three-piece comment | 1301 m Middle of a three-piece comment |
1289 | 1302 |
1290 e End of a three-piece comment | 1303 e End of a three-piece comment |
1291 | 1304 |
1292 l Left adjust middle with start or end (default). Only recognized when | 1305 l Left align. Used together with 's' or 'e', the leftmost character of |
1293 used together with 's' or 'e'. | 1306 start or end will line up with the leftmost character from the middle. |
1294 | 1307 This is the default and can be omitted. See below for more details. |
1295 r Right adjust middle with start or end. Only recognized when used | 1308 |
1296 together with 's' or 'e'. | 1309 r Right align. Same as above but rightmost instead of leftmost. See |
1297 | 1310 below for more details. |
1298 O Don't use this one for the "O" command. | 1311 |
1312 O Don't consider this comment for the "O" command. | |
1299 | 1313 |
1300 x Allows three-piece comments to be ended by just typing the last | 1314 x Allows three-piece comments to be ended by just typing the last |
1301 character of the end-comment string as the first character on a new | 1315 character of the end-comment string as the first action on a new |
1302 line, when the middle-comment string has already been inserted | 1316 line when the middle-comment string has been inserted automatically. |
1303 automatically. See below for more details. | 1317 See below for more details. |
1304 | 1318 |
1305 {digits} | 1319 {digits} |
1306 When together with 's' or 'e': add extra indent for the middle part. | 1320 When together with 's' or 'e': add {digit} amount of offset to an |
1307 This can be used to left-align the middle part with the start or end | 1321 automatically inserted middle or end comment leader. The offset begins |
1308 and then add an offset. | 1322 from a left alignment. See below for more details. |
1309 | 1323 |
1310 -{digits} | 1324 -{digits} |
1311 Like {digits} but reduce the indent. This only works when there is | 1325 Like {digits} but reduce the indent. This only works when there is |
1312 some indent for the start or end part that can be removed. | 1326 some indent for the start or end part that can be removed. |
1313 | 1327 |
1332 the comment does not continue on the next line. Three-piece comments must | 1346 the comment does not continue on the next line. Three-piece comments must |
1333 have a middle string because otherwise Vim can't recognize the middle lines. | 1347 have a middle string because otherwise Vim can't recognize the middle lines. |
1334 | 1348 |
1335 Notice the use of the "x" flag in the above three-piece comment definition. | 1349 Notice the use of the "x" flag in the above three-piece comment definition. |
1336 When you hit Return in a C-comment, Vim will insert the middle comment leader | 1350 When you hit Return in a C-comment, Vim will insert the middle comment leader |
1337 for the new line, e.g. " * ". To close this comment you just have to type "/" | 1351 for the new line: " * ". To close this comment you just have to type "/" |
1338 before typing anything else on the new line. This will replace the | 1352 before typing anything else on the new line. This will replace the |
1339 middle-comment leader with the end-comment leader, leaving just " */". There | 1353 middle-comment leader with the end-comment leader and apply any specified |
1340 is no need to hit BackSpace first. | 1354 alignment, leaving just " */". There is no need to hit BackSpace first. |
1341 | 1355 |
1342 Examples: > | 1356 |
1357 Here is an example of alignment flags at work to make a comment stand out | |
1358 (kind of looks like a 1 too). Consider comment string > | |
1359 sr:/***,m:**,ex2:******/ | |
1360 | |
1361 /*** | |
1362 **<--right aligned from "r" flag | |
1363 ** | |
1364 offset 2 spaces from the "2" flag--->** | |
1365 ******/ | |
1366 In this case, the first comment was typed, then return was pressed 4 times, | |
1367 then "/" was pressed to end the comment. | |
1368 | |
1369 Here are some finer points of three part comments. There are three times when | |
1370 alignment and offset flags are taken into consideration: opening a new line | |
1371 after a start-comment, opening a new line before an end-comment, and | |
1372 automatically ending a three-piece comment. The end alignment flag has a | |
1373 backwards perspective; the result is that the same alignment flag used with | |
1374 "s" and "e" will result in the same indent for the starting and ending pieces. | |
1375 Only one alignment per comment part is meant to be used, but an offset number | |
1376 will override the "r" and "l" flag. | |
1377 | |
1378 Enabling 'cindent' will override the alignment flags in many cases. | |
1379 Reindenting using a different method like |gq| or |=| will not consult | |
1380 alignment flags either. The same behaviour can be defined in those other | |
1381 formatting options. One consideration is that 'cindent' has additional options | |
1382 for context based indenting of comments but cannot replicate many three piece | |
1383 indent alignments. However, 'indentexpr' is has the ability to work better | |
1384 with three piece comments. | |
1385 | |
1386 Other examples: > | |
1343 "b:*" Includes lines starting with "*", but not if the "*" is | 1387 "b:*" Includes lines starting with "*", but not if the "*" is |
1344 followed by a non-blank. This avoids a pointer dereference | 1388 followed by a non-blank. This avoids a pointer dereference |
1345 like "*str" to be recognized as a comment. | 1389 like "*str" to be recognized as a comment. |
1346 "n:>" Includes a line starting with ">", ">>", ">>>", etc. | 1390 "n:>" Includes a line starting with ">", ">>", ">>>", etc. |
1347 "fb:-" Format a list that starts with "- ". | 1391 "fb:-" Format a list that starts with "- ". |
1348 | 1392 |
1349 By default, "b:#" is included. This means that a line that starts with | 1393 By default, "b:#" is included. This means that a line that starts with |
1350 "#include" is not recognized as a comment line. But a line that starts with | 1394 "#include" is not recognized as a comment line. But a line that starts with |
1351 "# define" is recognized. This is a compromise. | 1395 "# define" is recognized. This is a compromise. |
1352 | |
1353 Often the alignment can be changed from right alignment to a left alignment | |
1354 with an additional space. For example, for Javadoc comments, this can be | |
1355 used (insert a backslash before the space when using ":set"): > | |
1356 s1:/*,mb:*,ex:*/ | |
1357 Note that an offset is included with start, so that the middle part is left | |
1358 aligned with the start and then an offset of one character added. This makes | |
1359 it possible to left align the start and middle for this construction: > | |
1360 /** | |
1361 * comment | |
1362 */ | |
1363 | 1396 |
1364 {not available when compiled without the |+comments| feature} | 1397 {not available when compiled without the |+comments| feature} |
1365 | 1398 |
1366 *fo-table* | 1399 *fo-table* |
1367 You can use the 'formatoptions' option to influence how Vim formats text. | 1400 You can use the 'formatoptions' option to influence how Vim formats text. |
1389 When the 'c' flag is present this only happens for recognized | 1422 When the 'c' flag is present this only happens for recognized |
1390 comments. | 1423 comments. |
1391 n When formatting text, recognize numbered lists. This actually uses | 1424 n When formatting text, recognize numbered lists. This actually uses |
1392 the 'formatlistpat' option, thus any kind of list can be used. The | 1425 the 'formatlistpat' option, thus any kind of list can be used. The |
1393 indent of the text after the number is used for the next line. The | 1426 indent of the text after the number is used for the next line. The |
1394 default is to find a number, optionally be followed by '.', ':', ')', | 1427 default is to find a number, optionally followed by '.', ':', ')', |
1395 ']' or '}'. Note that 'autoindent' must be set too. Doesn't work | 1428 ']' or '}'. Note that 'autoindent' must be set too. Doesn't work |
1396 well together with "2". | 1429 well together with "2". |
1397 Example: > | 1430 Example: > |
1398 1. the first item | 1431 1. the first item |
1399 wraps | 1432 wraps |
1553 < To sort on the text at virtual column 10 (thus | 1586 < To sort on the text at virtual column 10 (thus |
1554 ignoring the difference between tabs and spaces): > | 1587 ignoring the difference between tabs and spaces): > |
1555 :sort /.*\%10v/ | 1588 :sort /.*\%10v/ |
1556 < To sort on the first number in the line, no matter | 1589 < To sort on the first number in the line, no matter |
1557 what is in front of it: > | 1590 what is in front of it: > |
1558 :sort /.*\ze\d/ | 1591 :sort /.\{-}\ze\d/ |
1559 | 1592 < (Explanation: ".\{-}" matches any text, "\ze" sets the |
1560 < With [r] sorting is done on the matching {pattern} | 1593 end of the match and \d matches a digit.) |
1594 With [r] sorting is done on the matching {pattern} | |
1561 instead of skipping past it as described above. | 1595 instead of skipping past it as described above. |
1562 For example, to sort on only the first three letters | 1596 For example, to sort on only the first three letters |
1563 of each line: > | 1597 of each line: > |
1564 :sort /\a\a\a/ r | 1598 :sort /\a\a\a/ r |
1565 | 1599 |