The VI editor is a standard editor for all UNIX and Linux systems. It is not inferior to any of the latest text editors. Here we just briefly introduce its usage and a few instructions. The VI editor is identical for any version of UNIX and Linux systems, so you can learn more about it in any other section about VI. VI is also the most basic text editor in Linux. After learning it, you will be able to enjoy the free access in the Linux World. Original article location
Original article location
1. Location of the original VI Concept
Basically, VI can be divided into three states: Command mode, insert mode, and last line mode. The functions of each mode are as follows: original article location
1) command line mode) original location
Controls the movement of the screen cursor, the deletion of characters, words, or rows, the movement of copying a segment and entering the insert mode, or to the last line mode. Original article location
2) insert mode: original position
You can enter text only in insert mode. Press ESC to return to command line mode. Original article location
3) location of the original text in the last line mode
Save the file or exit VI. You can also set the editing environment, such as searching strings and listing row numbers ...... . Original article location
Original article location
However, we generally simplify VI into two modes in use, that is, the last line mode is also included in the command line mode ). Original article location
2. Location of the original VI operation
A) enter the original VI Text Location
After the system prompts you to enter the VI and file name, you will be taken to the VI full-screen editing screen: Original Text Location
$ VI original myfile location
Note that after entering Vi, you are in command mode. You must switch to insert mode to Enter text. People who use VI for the first time will want to move the cursor first with the upper and lower right keys. As a result, the computer keeps beeping and getting angry with themselves. So after entering VI, do not tamper with the mouse, switch to "insert mode! Original article location
Original article location
B) switch to insert mode to edit the original file location
Click "I" under "command mode" to enter "insert mode". Then, you can enter the text. Original article location
Original article location
C) switch the original position of insert
You are currently in "insert mode", and you can only enter text all the time. If you find that you have entered an error! To move the word back with the light mark key, you must first Press ESC to switch to command mode and then delete the text. Original article location
Original article location
D) Exit VI and save the original file location
Under "command mode", click ":" colon to enter "last line mode", for example, the original position.
: W filename (enter "w filename" Article Save with the specified filename) original location
: WQ (enter "WQ" to save the disk and exit VI)
: Q! (Enter Q !, Do not save disk force exit VI) original location
Original article location
3. The original location of the function key in Command Line Mode
1) insert mode Original Text Location
Press "I" to switch to the insert mode "insert mode". Press "I" to enter the insert mode, and then enter the file starting from the current position of the cursor.
After you press "a" to enter the insert mode, enter the text from the next position where the cursor is currently located.
After you press "O" to enter the insert mode, a new row is inserted and text is entered from the beginning of the line. Original article location
Original article location
2) switch from the insert mode to the original location in the Command Line Mode
Press ESC. Original article location
Original article location
3) move the cursor's original position
VI can be moved up, down, left, and right directly with the cursor on the keyboard, but the regular VI uses lowercase letters "H", "J", "K", and "L 」, the cursor is controlled to move one cell to the left, down, up, and right respectively. Original article location
Press Ctrl + B to move the screen to the back. Original article location
Press Ctrl + F to move the screen to the front. Original article location
Press Ctrl + u to move the screen to the rear half of the page. Original article location
Press Ctrl + D to move the screen to front. Original article location
Press the number "0": to move to the beginning of the article. Original article location
Press g to move to the end of the article. Original article location
Press "$" to move to "end of line" of the row where the cursor is located ". Original article location
Press "^" to move the cursor to the "first line" original position in the row
Press W to jump to the beginning of the next word.
Press "E": the cursor jumps to the original text position of the next word
Press "B": the cursor is directed back to the beginning of the previous word.
Press # l to move the cursor to the # position of the row, such as 5l and 56l. Original article location
Original article location
4). Delete the original text location
"X": deletes the "Next" character at the cursor position every time you press it. Original article location
"# X": for example, "6x" indicates deleting the "Next" to the cursor position. Original article location
"X": uppercase X. Each time you press it, the "front" character of the cursor is deleted. Original article location
"# X": for example, "20x" indicates to delete the "front" of the cursor. Original article location
DD: Delete the row where the cursor is located. Original article location
「 # Dd 」: delete from the row where the cursor is located # position of the original line
Original article location
5). Copy the original text location
"Yw": copy the character at the end of the cursor to the buffer zone. Original article location
「 # YW 」: Copy # words to the buffer Original Text Location
"YY": copy the row where the cursor is located to the buffer zone. Original article location
"# YY": for example, "6yy" indicates copying 6 lines of text from the row where the cursor is located "down. Original article location
P: place the characters in the buffer to the cursor position. Note: All copy commands related to "Y" must work with "P" to complete the copy and paste function. Original article location
Original article location
6). Replace the original text location
"R": Replace the character at the cursor position. Original article location
"R": Replace the character wherever the cursor goes until you press the "ESC" key. Original article location
Original article location
7). Reply to the original position of the previous operation
"U": If you mistakenly execute a command, you can immediately press "U" to return to the previous operation. You can perform multiple replies for multiple times by "U. Original article location
Original article location
8). Change the original text location
"CW": change the word to the original text position at the end of the cursor.
"C # W": for example, "c3w" indicates changing the original three characters
Original article location
9). Jump to the original position of the specified row
CTRL + G lists the row numbers of the cursor. Original article location
"# G": for example, "15g" indicates moving the cursor to the first row of the article. Original article location
4. Introduction to the original command location in last line mode
Before using "last line mode", remember to press the "ESC" key to confirm that you are already in "command mode" and then press 「: "colon to enter" last line mode 」. Original article location
Original article location
A) list the positions of the original line numbers.
Original article location
"Set nu": After "set nu" is entered, the row number is listed before each row in the file. Original article location
Original article location
B) Jump to the original line of the file
Original article location
"#": "#" Indicates a number. Enter a number after the colon and press enter to jump to the row. For example, enter the number 15 and press Enter, this will jump to the second line of the article. Original article location
Original article location
C) locate the original character
Original article location
"/Keyword": First press the "/" key and then enter the character you want to search. If the first search keyword is not what you want, you can always press "N" until you find the keyword you want. Original article location
Original article location
「? Keyword: First press 「?」 Enter the character you want to search for. If the keyword you want for the first time is not what you want, you can press "N" until you find the keyword you want. Original article location
Original article location
D) Save the original file location
Original article location
"W": Enter "W" in the colon to save the file. Original article location
Original article location
E) leave the original VI File
Original article location
Q: Press Q to exit. If you cannot exit Vi, you can follow Q with 「!」 Force exit VI. Original article location
Original article location
"QW": it is generally recommended to use it with "W" when leaving, so that files can be saved when exiting. Original article location
Original article location
5. original location of the VI command list
1. The following table lists some key functions in command mode: original location
Original article location
H Original article location
Move the cursor left to the position of the original character
Original article location
L Original Text Location
Move the cursor right to the position of the original character
Original article location
K Original Text Location
Move the cursor above the original line
Original article location
J Original article location
Move the cursor down to the original line
Original article location
^ Original Text Location
Move the cursor to the beginning of the line
Original article location
0 Original article location
Number "0", move the cursor to the beginning of the article
Original article location
G Original Text Location
Move cursor to the last original article of the article
Original article location
$ Original Text Location
Move the cursor to the end of the line
Original article location
CTRL + F Original Text Location
Position of the original text on the front screen
Original article location
CTRL + B Original Text Location
Position of the original text on the backward Screen
Original article location
CTRL + D Original Text Location
Position of the first half screen
Original article location
CTRL + U Original Text Location
Position of the original half screen
Original article location
I Original article location
Insert the original character position before the cursor position
Original article location
Location of source
The last character in the cursor position begins to add the original position.
Original article location
O Original Text Location
Insert a new row and enter the original position from the beginning of the row.
Original article location
ESC Original Text Location
Return from input status to original command status
Original article location
X Original Text Location
Delete the original character position after the cursor
Original article location
# X Original Text Location
# Original character position after deleting the cursor
Original article location
X Original Text Location
(Uppercase X), delete the original character position before the cursor
Original article location
# X Original Text Location
Delete the # character original position before the cursor
Original article location
Dd Original Text Location
Delete the original row position of the cursor
Original article location
# Dd Original Text Location
Delete the number of rows from the cursor # original row position
Original article location
Original YW Text Location
Copy the original text position of the cursor
Original article location
# YW Original Text Location
Copy # original text position of the cursor
Original article location
YY Original Text Location
Copy the original line of the cursor
Original article location
# YY Original Text Location
Copy the number of rows from the cursor # The original row position
Original article location
Position of P Original
Paste original content
Original article location
U Original Text Location
Cancel operation Original Text Location
Original article location
CW Original Text Location
Change the original text position of the cursor
Original article location
# CW Original Text Location
Change the # original text position of the cursor
Original article location
Original article location
2. The following table lists the original commands in the travel command mode.
W filename original location
Store the file being edited as the original file location of filename
Original article location
Original location of WQ filename
Save the file being edited as filename and exit the original VI file.
Original article location
Q! Original article location
Discard all modifications and exit VI original
Original article location
Set nu Original Text Location
Show the original line number position
Original article location
/Or? Original article location
Search, enter the original content location after/
Original article location
N Original article location
And/or? If the search content is not the keyword, press N or backward (and/) or forward (and? Continue searching until it is found. Original article location
Original article location
Original article location
Note the following when using VI for the first time:
1. After opening a file with VI, it is in command mode. You must switch to insert mode to Enter text. Switch method: click "I" under "command mode" to enter "insert mode )」, now you can start to input text. Original article location
2. After editing, you must switch from the insert mode to the command line mode to save the file. to switch to the mode, Press ESC. Original article location
3. Save and exit the file: In command mode, enter WQ! (Don't forget the one before WQ)
VI User Manual
VI is the most commonly used text editing tool on Unix. As a UNIX Software tester, it is necessary to master it. Original article location Original article location Enter the original command location of vi VI filename: open or create a file and place the cursor at the first original line Vi + N filename: open the file and place the cursor in the first original text of line N Vi + filename: open the file and place the cursor at the beginning of the last line Vi +/pattern filename: open the file and place the cursor in the original position of the first string matching pattern VI-r filename: a system crash occurred when VI was being edited last time. restore the original location of filename. VI filename... filename: open multiple files and edit the original location in sequence Original article location Move the cursor command to the original position H: move the cursor to the left of the original character L: move the cursor one character to the right Space: move the cursor one character to the right Backspace: move the cursor to the left of the original character K or Ctrl + P: move the cursor up the position of the original line J or Ctrl + N: move the cursor down the position of the original line Enter: move the cursor down to the original line W or W: move one word to the beginning of the word B or B: move one word left to the beginning of the word E or E: Move a word J to the end of the source text ): Move the cursor to the end of the sentence (: Move the cursor to the beginning of the sentence }: Move the cursor to the beginning of the paragraph {: Move the cursor to the beginning of the paragraph NG: move the cursor to the beginning of line N. N +: move the cursor down n lines to the original position N-: Move n lines above the cursor N $: move the cursor to the end of line N. H: move the cursor to the original line on the screen M: move the cursor to the original line in the middle of the screen L: move the cursor to the original text on the last line of the screen 0: (Note that the number is zero) move the cursor to the beginning of the current line $: Move the cursor to the original text position at the end of the current row Original article location Original position of the screen tumble command CTRL + u: Position of the original half screen to the first part of the file CTRL + D: Position of the original half screen to the end of the file CTRL + F: Flip the original position to the end of the file CTRL + B; flip the original position to the first part of the file NZ: Rolls row n to the top of the screen. If n is not specified, the current row is rolled to the top of the screen. Original article location Original article location Insert original text commands I: Position of the original text before the cursor I: In the beginning of the current line A: Position of the original text behind the cursor A: The position of the original text at the end of the current line O: open a new line of original text under the current line O: Create a new line of original text on top of the current line R: replace the original position of the current character R: Replace the current and subsequent characters until you press the ESC key to start the original text. S: Starting from the current cursor position, replace the specified number of original characters with the input text S: delete a specified number of rows and replace the original text with the entered text NCW or NCW: modify the original position of a specified number of words NCC: modify the original location of a specified number of rows Original article location Delete the original command Ndw or ndw: Delete the n-1 original text position starting at and following the cursor Do: Delete the row to the beginning of the line. D $: Delete to the original position at the end of the line NDD: Delete the current row and the original location of the next n-1 row X or X: delete a character. x deletes the cursor, and X deletes the original text position before the cursor. CTRL + u: Delete the original text location in the input mode Original article location Search and replace command: Original Text Location /Pattern: Search for the original pattern position from the beginning of the cursor to the end of the file ? Pattern: searches for the original location of pattern from the beginning of the cursor. N: Repeat the previous search command in the same direction. N: Repeat the position of the original command in the reverse direction. : S/P1/P2/G: replace all p1 in the current row with p2 : N1, N2s/P1/P2/G: replace all P1 from line N1 to line N2 with p2 : G/P1/S // P2/G: replace all P1 files with p2 Original article location Option to set the original text location ALL: lists all options. Term: Set the original location of the terminal type. Ignorance: Ignore the original text location in case List: displays the original position of the Stop table (CTRL + I) and the end mark ($ ). Number: displays the original position of the row number. Report: displays the number of original texts modified by the line-oriented command. Terse: display the original text location of brief warning information Warn: When transferring to another file, if the current file is not saved, no write information is displayed. Nomagic: allows you to use the original location without a special character "\" in the search mode. Nowrapscan: forbid VI to start the original position from the other end when the search reaches both ends of the file. Mesg: Allows VI to display the original location of information written by other users to their terminal using write. Original article location Last line command original position : N1, N2 Co N3: copy the content from line N1 to line N2 to the original position under line N3. : N1, N2 M N3: Move the content from line N1 to line N2 to the original position under line N3. : N1, N2 D: Delete the original content from line N1 to line N2 : W: Save the original file location : E filename: open the file filename to edit the original file location. : X: Save the current file and exit the original file. : Q: exit the original VI position. : Q! : Do not save the file and exit the original VI position :! Command: Execute the shell command to the original location : N1, N2 W! Command: The content from line N1 to line N2 in the file is used as the command input and executed. If N1 or N2 is specified, the entire file content is used as the original location of the command input. : R! Command: place the output result of the command to the current line. |
|
|