summaryrefslogtreecommitdiff
path: root/runtime/doc/change.txt
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/doc/change.txt')
-rw-r--r--runtime/doc/change.txt132
1 files changed, 83 insertions, 49 deletions
diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt
index c1eed2c0a..24cf3fe9c 100644
--- a/runtime/doc/change.txt
+++ b/runtime/doc/change.txt
@@ -1,4 +1,4 @@
-*change.txt* For Vim version 7.1. Last change: 2007 Jan 07
+*change.txt* For Vim version 7.2a. Last change: 2008 Jun 22
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -229,16 +229,18 @@ key restores the original text (if there was any). (See section "Insert and
Replace mode" |mode-ins-repl|).
*cw* *cW*
-Special case: "cw" and "cW" work the same as "ce" and "cE" if the cursor is
-on a non-blank. This is because Vim interprets "cw" as change-word, and a
-word does not include the following white space. {Vi: "cw" when on a blank
-followed by other blanks changes only the first blank; this is probably a
-bug, because "dw" deletes all the blanks; use the 'w' flag in 'cpoptions' to
-make it work like Vi anyway}
+Special case: When the cursor is in a word, "cw" and "cW" do not include the
+white space after a word, they only change up to the end of the word. This is
+because Vim interprets "cw" as change-word, and a word does not include the
+following white space.
+{Vi: "cw" when on a blank followed by other blanks changes only the first
+blank; this is probably a bug, because "dw" deletes all the blanks; use the
+'w' flag in 'cpoptions' to make it work like Vi anyway}
If you prefer "cw" to include the space after a word, use this mapping: >
:map cw dwi
-<
+Or use "caw" (see |aw|).
+
*:c* *:ch* *:change*
:{range}c[hange][!] Replace lines of text with some different text.
Type a line containing only "." to stop replacing.
@@ -345,6 +347,10 @@ g?{motion} Rot13 encode {motion} text. {not in Vi}
g?g? *g?g?* *g??*
g?? Rot13 encode current line. {not in Vi}.
+To turn one line into title caps, make every first letter of a word
+uppercase: >
+ :s/\v<(.)(\w*)/\u\1\L\2/g
+
Adding and subtracting ~
*CTRL-A*
@@ -474,7 +480,7 @@ For example: >
A filter is a program that accepts text at standard input, changes it in some
way, and sends it to standard output. You can use the commands below to send
-some text through a filter, so that it is replace by the filter output.
+some text through a filter, so that it is replaced by the filter output.
Examples of filters are "sort", which sorts lines alphabetically, and
"indent", which formats C program files (you need a version of indent that
works like a filter; not all versions do). The 'shell' option specifies the
@@ -661,9 +667,9 @@ The flags that you can use for the substitute commands:
{not in Vi}
Note that there is no flag to change the "magicness" of the pattern. A
-different command is used instead. The reason is that the flags can only be
-found by skipping the pattern, and in order to skip the pattern the
-"magicness" must be known. Catch 22!
+different command is used instead, or you can use |/\v| and friends. The
+reason is that the flags can only be found by skipping the pattern, and in
+order to skip the pattern the "magicness" must be known. Catch 22!
If the {pattern} for the substitute command is empty, the command uses the
pattern from the last substitute or ":global" command. With the [r] flag, the
@@ -686,7 +692,9 @@ can use any other single-byte character, but not an alphanumeric character,
pattern or replacement string. Example: >
:s+/+//+
-For the definition of a pattern, see |pattern|.
+For the definition of a pattern, see |pattern|. In Visual block mode, use
+|/\%V| in the pattern to have the substitute work in the block only.
+Otherwise it works on whole lines anyway.
*sub-replace-special* *:s\=*
When the {string} starts with "\=" it is evaluated as an expression, see
@@ -1128,7 +1136,10 @@ nothing is returned. {not in Vi}
Contains the most recent search-pattern. This is used for "n" and 'hlsearch'.
It is writable with ":let", you can change it to have 'hlsearch' highlight
other matches without actually searching. You can't yank or delete into this
-register. {not in Vi}
+register. The search direction is available in |v:searchforward|.
+Note that the valued is restored when returning from a function
+|function-search-undo|.
+{not in Vi}
*@/*
You can write to a register with a ":let" command |:let-@|. Example: >
@@ -1253,9 +1264,11 @@ an external command, like "par" (e.g.: "!}par" to format until the end of the
paragraph) or set 'formatprg' to "par".
*format-comments*
-Vim can format comments in a special way. Vim recognizes a comment by a
-specific string at the start of the line (ignoring white space). Three types
-of comments can be used:
+An overview of comment formatting is in section |30.6| of the user manual.
+
+Vim can automatically insert and format comments in a special way. Vim
+recognizes a comment by a specific string at the start of the line (ignoring
+white space). Three types of comments can be used:
- A comment string that repeats at the start of each line. An example is the
type of comment used in shell scripts, starting with "#".
@@ -1263,7 +1276,7 @@ of comments can be used:
lines. An example is this list with dashes.
- Three-piece comments that have a start string, an end string, and optional
lines in between. The strings for the start, middle and end are different.
- An example is the C-style comment:
+ An example is the C style comment:
/*
* this is a C comment
*/
@@ -1289,23 +1302,24 @@ type of comment string. A part consists of:
e End of a three-piece comment
- l Left adjust middle with start or end (default). Only recognized when
- used together with 's' or 'e'.
+ l Left align. Used together with 's' or 'e', the leftmost character of
+ start or end will line up with the leftmost character from the middle.
+ This is the default and can be omitted. See below for more details.
- r Right adjust middle with start or end. Only recognized when used
- together with 's' or 'e'.
+ r Right align. Same as above but rightmost instead of leftmost. See
+ below for more details.
- O Don't use this one for the "O" command.
+ O Don't consider this comment for the "O" command.
x Allows three-piece comments to be ended by just typing the last
- character of the end-comment string as the first character on a new
- line, when the middle-comment string has already been inserted
- automatically. See below for more details.
+ character of the end-comment string as the first action on a new
+ line when the middle-comment string has been inserted automatically.
+ See below for more details.
{digits}
- When together with 's' or 'e': add extra indent for the middle part.
- This can be used to left-align the middle part with the start or end
- and then add an offset.
+ When together with 's' or 'e': add {digit} amount of offset to an
+ automatically inserted middle or end comment leader. The offset begins
+ from a left alignment. See below for more details.
-{digits}
Like {digits} but reduce the indent. This only works when there is
@@ -1334,12 +1348,42 @@ have a middle string because otherwise Vim can't recognize the middle lines.
Notice the use of the "x" flag in the above three-piece comment definition.
When you hit Return in a C-comment, Vim will insert the middle comment leader
-for the new line, e.g. " * ". To close this comment you just have to type "/"
+for the new line: " * ". To close this comment you just have to type "/"
before typing anything else on the new line. This will replace the
-middle-comment leader with the end-comment leader, leaving just " */". There
-is no need to hit BackSpace first.
-
-Examples: >
+middle-comment leader with the end-comment leader and apply any specified
+alignment, leaving just " */". There is no need to hit BackSpace first.
+
+
+Here is an example of alignment flags at work to make a comment stand out
+(kind of looks like a 1 too). Consider comment string >
+ sr:/***,m:**,ex2:******/
+
+ /***
+ **<--right aligned from "r" flag
+ **
+offset 2 spaces from the "2" flag--->**
+ ******/
+In this case, the first comment was typed, then return was pressed 4 times,
+then "/" was pressed to end the comment.
+
+Here are some finer points of three part comments. There are three times when
+alignment and offset flags are taken into consideration: opening a new line
+after a start-comment, opening a new line before an end-comment, and
+automatically ending a three-piece comment. The end alignment flag has a
+backwards perspective; the result is that the same alignment flag used with
+"s" and "e" will result in the same indent for the starting and ending pieces.
+Only one alignment per comment part is meant to be used, but an offset number
+will override the "r" and "l" flag.
+
+Enabling 'cindent' will override the alignment flags in many cases.
+Reindenting using a different method like |gq| or |=| will not consult
+alignment flags either. The same behaviour can be defined in those other
+formatting options. One consideration is that 'cindent' has additional options
+for context based indenting of comments but cannot replicate many three piece
+indent alignments. However, 'indentexpr' is has the ability to work better
+with three piece comments.
+
+Other examples: >
"b:*" Includes lines starting with "*", but not if the "*" is
followed by a non-blank. This avoids a pointer dereference
like "*str" to be recognized as a comment.
@@ -1350,17 +1394,6 @@ By default, "b:#" is included. This means that a line that starts with
"#include" is not recognized as a comment line. But a line that starts with
"# define" is recognized. This is a compromise.
-Often the alignment can be changed from right alignment to a left alignment
-with an additional space. For example, for Javadoc comments, this can be
-used (insert a backslash before the space when using ":set"): >
- s1:/*,mb:*,ex:*/
-Note that an offset is included with start, so that the middle part is left
-aligned with the start and then an offset of one character added. This makes
-it possible to left align the start and middle for this construction: >
- /**
- * comment
- */
-
{not available when compiled without the |+comments| feature}
*fo-table*
@@ -1391,7 +1424,7 @@ a Automatic formatting of paragraphs. Every time text is inserted or
n When formatting text, recognize numbered lists. This actually uses
the 'formatlistpat' option, thus any kind of list can be used. The
indent of the text after the number is used for the next line. The
- default is to find a number, optionally be followed by '.', ':', ')',
+ default is to find a number, optionally followed by '.', ':', ')',
']' or '}'. Note that 'autoindent' must be set too. Doesn't work
well together with "2".
Example: >
@@ -1555,9 +1588,10 @@ found here: |sort()|.
:sort /.*\%10v/
< To sort on the first number in the line, no matter
what is in front of it: >
- :sort /.*\ze\d/
-
-< With [r] sorting is done on the matching {pattern}
+ :sort /.\{-}\ze\d/
+< (Explanation: ".\{-}" matches any text, "\ze" sets the
+ end of the match and \d matches a digit.)
+ With [r] sorting is done on the matching {pattern}
instead of skipping past it as described above.
For example, to sort on only the first three letters
of each line: >