~ubuntu-branches/ubuntu/vivid/vim/vivid

« back to all changes in this revision

Viewing changes to runtime/doc/change.txt

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2008-11-05 11:37:43 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20081105113743-9i4urcsm3n44mhqe
Tags: 2:7.2.025-2ubuntu1
* Merge from debian unstable, remaining changes:
  - runtime/syntax/debcontrol.vim:
    + Add "metapackages" to the list of valid sections.
  - runtime/syntax/debchangelog.vim:
    + Add "jaunty" to the list of valid suites.
  - Drop vim-lesstif package and lesstif2-dev build-dependency.
  - Enable Python interpreter on basic builds.
  - Create a .pot file for translations.
  - Disable autoindent, line-wrapping, and backup files by default.
  - runtime/syntax/debsources.vim:
    + Add "jaunty" to debsourcesDistrKeyword
  - runtime/syntax/grub.vim:
    + Add Ubuntu-specific 'quiet' keyword.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
*change.txt*    For Vim version 7.1.  Last change: 2007 Jan 07
 
1
*change.txt*    For Vim version 7.2.  Last change: 2008 Jul 24
2
2
 
3
3
 
4
4
                  VIM REFERENCE MANUAL    by Bram Moolenaar
229
229
Replace mode" |mode-ins-repl|).
230
230
 
231
231
                                                *cw* *cW*
232
 
Special case: "cw" and "cW" work the same as "ce" and "cE" if the cursor is
233
 
on a non-blank.  This is because Vim interprets "cw" as change-word, and a
234
 
word does not include the following white space.  {Vi: "cw" when on a blank
235
 
followed by other blanks changes only the first blank; this is probably a
236
 
bug, because "dw" deletes all the blanks; use the 'w' flag in 'cpoptions' to
237
 
make it work like Vi anyway}
 
232
Special case: When the cursor is in a word, "cw" and "cW" do not include the
 
233
white space after a word, they only change up to the end of the word.  This is
 
234
because Vim interprets "cw" as change-word, and a word does not include the
 
235
following white space.
 
236
{Vi: "cw" when on a blank followed by other blanks changes only the first
 
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
240
If you prefer "cw" to include the space after a word, use this mapping: >
240
241
        :map cw dwi
241
 
<
 
242
Or use "caw" (see |aw|).
 
243
 
242
244
                                                        *:c* *:ch* *:change*
243
245
:{range}c[hange][!]     Replace lines of text with some different text.
244
246
                        Type a line containing only "." to stop replacing.
345
347
g?g?                                                    *g?g?* *g??*
346
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
355
Adding and subtracting ~
350
356
                                                        *CTRL-A*
474
480
 
475
481
A filter is a program that accepts text at standard input, changes it in some
476
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
484
Examples of filters are "sort", which sorts lines alphabetically, and
479
485
"indent", which formats C program files (you need a version of indent that
480
486
works like a filter; not all versions do).  The 'shell' option specifies the
661
667
        {not in Vi}
662
668
 
663
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
665
 
found by skipping the pattern, and in order to skip the pattern the
666
 
"magicness" must be known.  Catch 22!
 
670
different command is used instead, or you can use |/\v| and friends.  The
 
671
reason is that the flags can only be found by skipping the pattern, and in
 
672
order to skip the pattern the "magicness" must be known.  Catch 22!
667
673
 
668
674
If the {pattern} for the substitute command is empty, the command uses the
669
675
pattern from the last substitute or ":global" command.  With the [r] flag, the
686
692
pattern or replacement string.  Example: >
687
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
699
                                        *sub-replace-special* *:s\=*
692
700
When the {string} starts with "\=" it is evaluated as an expression, see
764
772
the expression cannot use "\=" for the substitute string.
765
773
 
766
774
The special meaning for characters as mentioned at |sub-replace-special| does
767
 
not apply except "<CR>", "\<CR>" and "\\".  Thus in the result of the
768
 
expression you need to use two backslashes get one, put a backslash before a
769
 
<CR> you want to insert and use a <CR> without a backslash where you want to
 
775
not apply except for "<CR>", "\<CR>" and "\\".  Thus in the result of the
 
776
expression you need to use two backslashes to get one, put a backslash before a
 
777
<CR> you want to insert, and use a <CR> without a backslash where you want to
770
778
break the line.
771
779
 
772
780
For convenience a <NL> character is also used as a line break.  Prepend a
789
797
This replaces an end-of-line with a new line containing the value of $HOME. >
790
798
 
791
799
        s/E/\="\<Char-0x20ac>"/g
792
 
This replaces 'E' characters with an euro sign. Read more in |<Char->|.
 
800
This replaces each 'E' character with a euro sign.  Read more in |<Char->|.
793
801
 
794
802
 
795
803
4.3 Search and replace                                  *search-replace*
1128
1136
Contains the most recent search-pattern.  This is used for "n" and 'hlsearch'.
1129
1137
It is writable with ":let", you can change it to have 'hlsearch' highlight
1130
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
1145
You can write to a register with a ":let" command |:let-@|.  Example: >
1253
1264
paragraph) or set 'formatprg' to "par".
1254
1265
 
1255
1266
                                                        *format-comments*
1256
 
Vim can format comments in a special way.  Vim recognizes a comment by a
1257
 
specific string at the start of the line (ignoring white space).  Three types
1258
 
of comments can be used:
 
1267
An overview of comment formatting is in section |30.6| of the user manual.
 
1268
 
 
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
1273
- A comment string that repeats at the start of each line.  An example is the
1261
1274
  type of comment used in shell scripts, starting with "#".
1263
1276
  lines.  An example is this list with dashes.
1264
1277
- Three-piece comments that have a start string, an end string, and optional
1265
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
1281
         * this is a C comment
1269
1282
         */
1289
1302
 
1290
1303
  e     End of a three-piece comment
1291
1304
 
1292
 
  l     Left adjust middle with start or end (default).  Only recognized when
1293
 
        used together with 's' or 'e'.
1294
 
 
1295
 
  r     Right adjust middle with start or end.  Only recognized when used
1296
 
        together with 's' or 'e'.
1297
 
 
1298
 
  O     Don't use this one for the "O" command.
 
1305
  l     Left align. Used together with 's' or 'e', the leftmost character of
 
1306
        start or end will line up with the leftmost character from the middle.
 
1307
        This is the default and can be omitted. See below for more details.
 
1308
 
 
1309
  r     Right align. Same as above but rightmost instead of leftmost. See
 
1310
        below for more details.
 
1311
 
 
1312
  O     Don't consider this comment for the "O" command.
1299
1313
 
1300
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
1302
 
        line, when the middle-comment string has already been inserted
1303
 
        automatically.  See below for more details.
 
1315
        character of the end-comment string as the first action on a new
 
1316
        line when the middle-comment string has been inserted automatically.
 
1317
        See below for more details.
1304
1318
 
1305
1319
  {digits}
1306
 
        When together with 's' or 'e': add extra indent for the middle part.
1307
 
        This can be used to left-align the middle part with the start or end
1308
 
        and then add an offset.
 
1320
        When together with 's' or 'e': add {digit} amount of offset to an
 
1321
        automatically inserted middle or end comment leader. The offset begins
 
1322
        from a left alignment. See below for more details.
1309
1323
 
1310
1324
  -{digits}
1311
1325
        Like {digits} but reduce the indent.  This only works when there is
1334
1348
 
1335
1349
Notice the use of the "x" flag in the above three-piece comment definition.
1336
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
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
1340
 
is no need to hit BackSpace first.
1341
 
 
1342
 
Examples: >
 
1353
middle-comment leader with the end-comment leader and apply any specified
 
1354
alignment, leaving just " */".  There is no need to hit BackSpace first.
 
1355
 
 
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
1387
   "b:*"        Includes lines starting with "*", but not if the "*" is
1344
1388
                followed by a non-blank.  This avoids a pointer dereference
1345
1389
                like "*str" to be recognized as a comment.
1350
1394
"#include" is not recognized as a comment line.  But a line that starts with
1351
1395
"# define" is recognized.  This is a compromise.
1352
1396
 
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
 
 
1364
1397
{not available when compiled without the |+comments| feature}
1365
1398
 
1366
1399
                                                        *fo-table*
1391
1424
n       When formatting text, recognize numbered lists.  This actually uses
1392
1425
        the 'formatlistpat' option, thus any kind of list can be used.  The
1393
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
1428
        ']' or '}'.  Note that 'autoindent' must be set too.  Doesn't work
1396
1429
        well together with "2".
1397
1430
        Example: >
1528
1561
 
1529
1562
                        With [n] sorting is done on the first decimal number
1530
1563
                        in the line (after or inside a {pattern} match).
 
1564
                        One leading '-' is included in the number.
1531
1565
 
1532
1566
                        With [x] sorting is done on the first hexadecimal
1533
1567
                        number in the line (after or inside a {pattern}
1534
1568
                        match).  A leading "0x" or "0X" is ignored.
 
1569
                        One leading '-' is included in the number.
1535
1570
 
1536
1571
                        With [o] sorting is done on the first octal number in
1537
1572
                        the line (after or inside a {pattern} match).
1555
1590
                                :sort /.*\%10v/
1556
1591
<                       To sort on the first number in the line, no matter
1557
1592
                        what is in front of it: >
1558
 
                                :sort /.*\ze\d/
1559
 
 
1560
 
<                       With [r] sorting is done on the matching {pattern}
 
1593
                                :sort /.\{-}\ze\d/
 
1594
<                       (Explanation: ".\{-}" matches any text, "\ze" sets the
 
1595
                        end of the match and \d matches a digit.)
 
1596
                        With [r] sorting is done on the matching {pattern}
1561
1597
                        instead of skipping past it as described above.
1562
1598
                        For example, to sort on only the first three letters
1563
1599
                        of each line: >