For other systems the default value is different. Thus you can make a search
pattern with "\f" to match a file name, and it will automatically adjust to
the system you are using it on.
Note:
Actually, Unix allows using just about any character in a file name,
including white space. Including these characters in 'isfname' would
be theoretically correct. But it would make it impossible to find the
end of a file name in text. Thus the default value of 'isfname' is a
compromise.
The character classes are:
item matches option ~
\i identifier characters 'isident'
\I like \i, excluding digits
\k keyword characters 'iskeyword'
\K like \k, excluding digits
\p printable characters 'isprint'
\P like \p, excluding digits
\f file name characters 'isfname'
\F like \f, excluding digits
==============================================================================
*27.8* Matching a line break
Vim can find a pattern that includes a line break. You need to specify where
the line break happens, because all items mentioned so far don't match a line
break.
To check for a line break in a specific place, use the "\n" item: >
/one\ntwo
This will match at a line that ends in "one" and the next line starts with
"two". To match "one two" as well, you need to match a space or a line
break. The item to use for it is "\_s": >
/one\_stwo
To allow any amount of white space: >
/one\_s\+two
This also matches when "one " is at the end of a line and " two" at the
start of the next one.
"\s" matches white space, "\_s" matches white space or a line break.
Similarly, "\a" matches an alphabetic character, and "\_a" matches an
alphabetic character or a line break. The other character classes and ranges
can be modified in the same way by inserting a "_".
Many other items can be made to match a line break by prepending "\_". For
example: "\_." matches any character or a line break.
Note:
"\_.*" matches everything until the end of the file. Be careful with
this, it can make a search command very slow.
Another example is "\_[]", a character range that includes a line break: >
/"\_[^"]*"
This finds a text in double quotes that may be split up in several lines.
==============================================================================
*27.9* Examples
Here are a few search patterns you might find useful. This shows how the
items mentioned above can be combined.
FINDING A CALIFORNIA LICENSE PLATE
A sample license plate number is "1MGU103". It has one digit, three uppercase
letters and three digits. Directly putting this into a search pattern: >
/\d\u\u\u\d\d\d
Another way is to specify that there are three digits and letters with a
count: >
/\d\u\{3}\d\{3}
Using [] ranges instead: >
/[0-9][A-Z]\{3}[0-9]\{3}
Which one of these you should use? Whichever one you can remember. The
simple way you can remember is much faster than the fancy way that you can't.
If you can remember them all, then avoid the last one, because it's both more
typing and slower to execute.
FINDING AN IDENTIFIER
In C programs (and many other computer languages) an identifier starts with a
letter and further consists of letters and digits. Underscores can be used
too. This can be found with: >
/\<\h\w*\>
"\<" and "\>" are used to find only whole words. "\h" stands for "[A-Za-z_]"
and "\w" for "[0-9A-Za-z_]".
Note:
"\<" and "\>" depend on the 'iskeyword' option. If it includes "-",
for example, then "ident-" is not matched. In this situation use: >
/\w\@<!\h\w*\w\@!
<
This checks if "\w" does not match before or after the identifier.
See |/\@<!| and |/\@!|.
==============================================================================
Next chapter: |usr_28.txt| Folding
Copyright: see |manual-copyright| vim:tw=78:ts=8:noet:ft=help:norl: