The basic concept of "Linux" VI __linux

Source: Internet
Author: User
Tags save file

The basic concept of VI
Basically, vi can be divided into three operating states, namely command mode, insert mode (insert modes), and bottom line command mode,
The functions of each pattern are distinguished as follows:
1. Comand Mode: Controls the movement of the screen cursor, the deletion of the character or cursor, the movement of a section and into the insert mode, or the last line mode.
2. Insert mode: Only in insert mode, you can do text data input, press ESC, etc. can return to comand mode.
3. Last line mode: You can save files or leave the editor, or set up an editing environment, such as finding a string, listing line numbers, and so on.

Order to enter VI
VI FileName: Open or create a new file and place the cursor at the beginning of the first line
VI +n FileName: Open the file and place the cursor at the beginning of Nth line (the plus sign here is the real input)
VI + FileName: Open the file and place the cursor at the end of the line
VI +/pattern FileName: Open the file and place the cursor in the first matching string
Vi-r filename: A system crash occurred during the last edit with VI, filename restored
VI filename....filename: Open multiple files, edit in sequence

Move Cursor Class command
H: Move the cursor one character to the left
L: The cursor moves one character to the right
Space: The cursor moves one character to the right
Backspace: Move the cursor one character to the left
K or ctrl+p: Move the cursor up one line
J or CTRL + N: Move the cursor down one line
Enter: Move the cursor down one line
W or W: Move the cursor right one word to the top of the word
B or B: Move the cursor left one word to the top of the word
E or E: Move the cursor right one word to the end of the word
): The cursor moves to the end of the sentence
(: The cursor moves to the beginning of the sentence
}: The cursor moves to the beginning of the paragraph
{: The cursor moves to the end of the paragraph
NG: The cursor moves to the beginning of nth
n+: Move the cursor down n line
N: Move n line up on cursor
n$: The cursor moves to the end of the nth line
H: The cursor moves to the top line of the screen
M: The cursor moves to the middle line of the screen
L: The cursor moves to the last line of the screen
0: (note is the number 0) the cursor moves to the current beginning
$: The cursor moves to the end of the current line

Insert text Class command (switch to command mode method: Esc key-> Command-> carriage return)
I: Before the cursor
I: At the beginning of the current
A: After the cursor
A: At the end of the current line
O: Open a new row below the current line
O: Open a new line above the current line
R: Replace the current character
R: Replaces the current character and its subsequent characters until the ESC key is pressed
S: replaces the specified number of characters with the input text, starting at the current cursor position
S: Deletes the specified number of rows and replaces them with the text entered
NCW or NCW: Modifying a specified number of words
NCC: Modify specified number of rows

Delete command
NDW or NDW: Deletes the beginning of the cursor and the n-1 word after it
Do: Delete to the beginning of the line
d$: Delete to end of line
NDD: Deletes the current row and its n-1 line
X or x: Deletes a character, x deletes the cursor, and x deletes the cursor before the
Ctrl+u: Deletes the text entered in the input mode

Exit (save or do not save exit) command

: Wq mandatory write file and exit. Force write even if the file has not been modified, and update the file's modification time.

: X writes to the file and exits. The file modification time is not updated until the file is modified and the file modification time is updated.

: q! Do not save file and Exit VI

Related Article

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.