Vi/vim of Linux

Source: Internet
Author: User

Reference from: http://www.cnblogs.com/itech/archive/2009/04/17/1438439.html

ITech
Source: http://itech.cnblogs.com/

Re-editing, only keep the usual commands, and add a little understanding and experience.

1, VI of the basic concept

Basically, vi can be divided into three states, namely command mode, insert mode (and bottom line mode), and the function of each mode is as follows:
1) command-line mode
Controls the movement of the screen cursor, the deletion of characters, words, or lines, moving and copying a section and entering insert mode, or to last line mode.

My understanding: The (Edit) menu in WordPad
2) Insert mode
Only in the Insert mode, you can do text input, press "esc" to return to the command line mode.

My understanding: In WordPad, press the mouse to edit the page, the entire keyboard to make the whole.
3) Bottom Line mode
Save or Exit VI, or you can set the editing environment, such as looking for a string, listing line numbers ... such as

My understanding: In WordPad (file) and (Settings) menu

2. Operation of VI

1) Enter VI

$ VI myfile means: Enter vi+ space + the name of the file you want to open

2) exit

"Esc+: q! "Means: First click the ESC key to enter the bottom row mode, enter a colon, enter q!, do not save the forced Exit VI, equivalent to WordPad (exit).

"esc+: w filename" means: First click the ESC key to enter the bottom line mode, enter a colon, enter w+ to save the file name, equivalent to WordPad (Save As).

"Esc:wq" means: first click the ESC key into the bottom row mode, enter a colon, enter the WQ, directly save and exit VI, equivalent to WordPad (save).

3) Edit the file

Click "I", enter the editing mode, can be typed at the cursor position character, the equivalent of a mouse click, that is point.

Click "A" to enter edit mode, starting at the next position of the cursor.

Click "O" to enter edit mode and start typing from a new line.

4) Move cursor

Generally with the arrow on the line, not to enter the loading mode in the command mode with "H" "J" "K" "L" control left, bottom, upper, right.

Press "Ctrl+b": the screen moves to "after" one page.
Press "Ctrl+f": the screen moves to "front" one page.
Press "Ctrl+u": The screen moves the half page toward "rear".
Press "Ctrl+d": The screen moves the half page toward "front".

Press "G": Move to the beginning of the article, pay attention to the capital G, engaged in a half day.

Press #l: The cursor moves to the position of the first # character of the line, such as: 5l,56l.

5) Enter characters

Knock on the keyboard, nothing else.

6) Delete characters

Press "X" once to delete one character after the cursor

Press "number +x" to delete the number of characters after the cursor

Press "DD" to delete the line where the cursor is located

Press "number +dd" to delete the number of digits following the cursor.

7) Copying characters

Press "number +yw" to copy the cursor and enter the number of words (this word refers to the word, not the letter)

Press "yy" to copy the cursor in the row

Press "Digital +yy" to copy the cursor down to enter the number of rows

8) Paste

Press "P" to paste from the cursor position

9) Revocation

Press "U" to undo the last command

10) Skip to the specified line

"Number +g" jumps to the beginning of the input number

11) Save

"Esc+:w" means to press ESC to enter command mode, press the colon, press W to save the file

12) List Line numbers

"Esc+:set nu" means to press ESC into command mode, press the colon, enter set, Space, Nu, automatically list line numbers

"Esc+:set Nonu" remove line number

13) Find

"esc+:/to find the word" means to press ESC into the command mode, by colon, enter/, enter the word to find, carriage return, find the first word, always press N to query

"Esc+:?" To find the word "means press ESC into command mode, by colon, enter?" , enter the word to look for, enter, find the first word, always press n forward Query

Summary:

1, in addition to editing the document, all operations are to first press the ESC key, enter the edit mode after the command to operate.

2. Case-sensitive

3, in fact, the overall thinking and Windows WordPad, Notepad is the same, just Linux black and white screen no way with the mouse, smart command, and command and document input all have to use the keyboard, so you have to distinguish between input mode and command mode.

4, function and Notepad are the same, but with the command, with more than remember.

Spit Groove:

Linux is not designed for the general user, it is purely for professionals. And the location of Windows is fundamentally different, in that case, what is the point of imitating windows? Do what Linux should do.

Master's mind Mapping

Vi/vim of Linux

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.