Learn VI Editor-quick move

Source: Internet
Author: User

2011-06-03 wcdj

 

(1) move by Screen
(2) move by text block
(3) Move by search
(4) move by row number

 

(1) move by Screen


(1) scroll Screen

"One screen"
CTRL + F scroll forward
CTRL + B scroll back one screen
"Half screen"
CTRL + D scroll forward half screen (bottom)
CTRL + u scroll back half screen (on)
"One row"
CTRL + e scroll up a row
CTRL + y scroll down a row
Note: The two commands do not position the cursor at the beginning of the line. When the two commands are called, the cursor remains the original position in the line.

(2) Use Z to reposition the screen

Z + return move the current row to the top of the screen and scroll
Z +. Move the current row to the center of the screen and scroll
Z +-Move the current row to the bottom of the screen and scroll

(3) refresh the screen

CTRL + L refresh the screen without scrolling

(4) move in the screen

H move to the starting point-the first line of the screen
M moves to the middle line of the screen
L move to the end of the row on the screen
NH moves to line N below the first line of the screen
Line N at the end of the line to which NL moves to the screen

(5) move by row

In addition to moving the cursor J (down) and K (up), there are:
Return move to the first character of the next line
+ Move to the first character of the next line
-Move to the first character of the previous line

(6) move in the current row

In addition to H (left) and L (right) move the cursor, 0 (first row) and $ (last row) move the cursor, and:
^ Move to the first non-space character of the current row
N + | move to column N of the current row

(2) move by text block


Another way to move in a VI file is to move by text blocks (words, sentences, paragraphs, or sections.
Except:
W or W move forward by words
Move B or B behind words
Also:
E. Move to the end of the word
E. Move to the end of the word (ignore punctuation)
(Move to the beginning of the current sentence
) Move to the beginning of the next sentence
{Move to the beginning of the current section (next section)
} Move to the beginning of the current section (previous section)
[[Move to the beginning of the current section (next section)
] Move to the beginning of the current section (previous section)

Note: You can combine numbers with mobile commands. For example:
3) Move three sentences forward
D) Delete the text at the end of the current sentence
2y} copy the first two paragraphs

(3) Move by search


The search command is a special character/(slash ).
When you enter a slash, it will appear on the bottom line of the screen, and then you can enter the mode you want to search. /Pattern + return
The pattern can be an entire word or any other character sequence (also known as a "string ").
VI searches forward from the cursor. If necessary, you can move the cursor to the beginning of the file. The cursor moves to the position where the mode appears for the first time. If no matching text is found, VI displays the "pattern not found" information on the status line.

Note:/(slash) is used for forward search and Backward Search? (Question mark ).

(1) repeated search

The previous search mode is available throughout the editing session. After a search, you can use the research command in the previous mode to avoid repeating the original key.
N repeated searches in the Same Direction
N reverse repeat search
/+ Return repeated search forward
? + Return repeated search

Note: VI has a "wrapscan" option, which can control whether to fold back for search.
: Set nowrapscan cancel fold-back search
: Set wrapscan enable fold-back search

(2) Intra-row search

F also serves to search for micro-version commands in the current line.
FX searches (moves the cursor to) the next instance of X within the row. Here X represents any character
FX searches within a row (move the cursor to) the previous instance of X
TX search (move cursor to) characters before the next instance X in the row
TX searches within a row (move the cursor to) the character following the previous instance of X
; Repeat the previous search command in the Same Direction
, Repeat the previous search command in the opposite direction

Note:
(1) DFX deletes text between the specified character X (including X). This command is often used to delete or copy part of the text in a row. Because it is difficult to count words if there are symbols or punctuation in the row, DFX may be used instead of DW.
(2) In addition to positioning the cursor before the search character, the T command serves the same purpose as F. For example, the CT. Command can modify all texts at the end of a sentence and retain the periods.

(4) move by row number


The lines in the file are sequentially numbered, so you can move them in the file by specifying the row number.
: Se nu: display the row number
: Se Nonu does not display row numbers
Because the error message of the compiled program specifies the row number, it is very useful for programmers.

Note: The CTRL + G command displays the line number and other information at the bottom of the screen (including the current line number, the total number of lines of the file, and the percentage of the current row in the total line ).

G (transfer) command
You can use the row number to move the cursor in the file. The G (transfer) command uses the row number as the numeric parameter and moves directly to that line. For example:
12g move the cursor to the beginning of the first line
G commands without line numbers move the cursor to the end of the file.

Note: Two quotation marks ('') and one pair of single quotation marks ('')
If no edits are made during this period, you can enter two backticks ('') to return to the original location (the location where the G command was last called ).
If you have edited the cursor and then use a command different from G to move the cursor, ''will return the cursor to the Last edited position.
If you have already called the SEARCH Command (// or ?), Then ''will return the cursor to the start position of the search.

A pair of single quotes (''), apart from returning the cursor to the beginning of the line rather than the exact position where the cursor was previously located, have a similar effect with two reverse quotes.

You can use Ctrl + G to display the total number of rows that you want to move.

Moving by row number allows you to quickly move from one location to another in a large file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.