- 论坛徽章:
- 0
|
non-blank character on a line. If you have left only a single space
following a period, or if the sentence ends with a quotation mark, vi
won't recognize the sentence.
A paragraph is defined as text up to the next blank line, or up to
one of the default paragraph macros (.IP, .PP, .LP, or .QP) from the
troff MS macro package. Similarly, a section is defined as text up to
the next default section macro (.NH, .SH, .H 1, .HU). The macros
that are recognized as paragraph or section separators can be
customized with the :set command, as described in Chapter 7.
Remember that you can combine numbers with movement. For
example, 3) moves ahead three sentences. Also remember that you
can edit using movement commands: d) deletes to the end of the
current sentence, 2y} copies (yanks) two paragraphs ahead.
3.3 Movement by Searches
One of the most useful ways to move around in a large file
quickly is by searching for text, or more properly, a pattern of
characters. Sometimes a search can be performed to find a
misspelled word or to find each occurrence of a variable in a
program.
The search command is the special character / (slash). When you
enter a slash, it appears on the bottom line of the screen; you then
type in the pattern that you want to find: /pattern.
A pattern can be a whole word or any other sequence of characters
(called a "character string"). For example, if you search for the
characters red, you will match red as a whole word, but you'll also
match occurred. If you include a space before or after pattern, the
spaces will be treated as part of the word. As with all bottom-line
commands, press RETURN to finish. vi, like all other UNIX editors,
has a special pattern-matching language that allows you to look for
variable text patterns; for example, any word beginning with a
capital letter, or the word The at the beginning of a line.
We'll talk about this more powerful pattern-matching syntax in
Chapter 6. For right now, think of pattern simply as a word or
phrase.
vi begins the search at the cursor and searches forward, wrapping
around to the start of the file if necessary. The cursor will move to
the first occurrence of the pattern. If there is no match, the
message "Pattern not found" will be shown on the status line.[1] |
|