VI Common Command line
1.VI mode
A) General mode: VI when processing a file, one enters the file, which is the general mode.
b) Edit mode: In general mode can be deleted, copy, paste and other operations, but unable to edit the operation. Press the ' I,i,o,o,a,a,r,r ' and so on
To enter edit mode. Usually in Linux, when the above letter is pressed, the words ' INSERT ' or ' REPLACE ' will appear in the lower left to
Enter any text into the file. To return to normal mode, press the [ESC] key.
c) command-line mode: In general mode, enter ": OR/or?" To move the cursor to the bottom line, in which you can search for data and read,
Save, delete a lot of characters, leave VI, display line number and other operations.
2.VI Common Command Summary:
2.1 General Mode
A) Move the cursor:
-Up and DOWN ARROW keys ↑↓←→
--Page Pagedown/pageup button
--Number 0: Move the cursor to the beginning of the current line
--$: Move the cursor to the end of the current line
-G: Move to the last line of this file ng:n to the number, moving to the nth row of this file.
--GG: The first line moved to this file is equivalent to 1G
b) Search and replace
--/word: From the beginning of the cursor, query down a string named word.
--: N1, n2s/word1/word2/g: N1 and N2 are numbers. Search for N1 between N2 and Word1 lines,
and replace the string with Word2.
---1, $s/word1/word2/g: look for the word1 string from the first line to the last line, and replace the string with Word2
---1, $s/word1/word2/gc: look for the word1 string from the first line to the last line, and replace the string with Word2.
And show the prompt to the user before replacing (conform) if a replacement is required.
c) Delete, copy, paste
--x,x: In one row, X is to remove a character backwards (equivalent to the DEL key) and X to delete a character (equivalent to the BACKSPACE key) forward.
-DD: Deletes the entire line where the cursor is located.
--Ndd:n is a number. From the beginning of the cursor, delete the down n column.
-YY: The line where the cursor is copied.
--Nyy:n is a number. The next n rows where the cursor is copied.
--P,p:p to paste the copied data to the next line of the cursor, p is the last line attached to the cursor.
-U: Undo Previous Action
-CTRL + R: Redo the last action.
--The decimal point '. ': Repeats the previous action.
2.2 Edit mode:
A) I, I: Insert the input text at the cursor location, and the existing text is backward. I is ' inserting ' from the current cursor, I is ' inserting ' at a non-space character in the current row.
b) A, a:a is ' insert from the next character where the current cursor is located '. A is ' insert at the last character of the line where the cursor is located '.
c) O,o: This is the case of the English O. o Insert a new line at the next line in the row where the current cursor is located. O means ' insert a new line at the top of the line where the current cursor is located '.
d) R,r: Replace: R replaces the one character where the cursor is located. R: The character of the cursor is always replaced until the ESC key is pressed.
e) ESC: Enter general mode.
2.3 Command mode:
A): W: Write the edited data to the hard disk
b): Q: Leave VI
c): q! : Forced departure, not stored
d): Wq: Left after storage
E): wq! : Force storage after leaving
3. Vim Additional command line
3.1 Block Selection (visual block)
V-character selection, where the cursor passes through the counter-white display
V-line selection, the line that the cursor passes through is white
Ctrl + V block selection, you can select the data in a rectangular way
Y Copy the anti-white place
D Remove the anti-white place
3.2 Multi-file editing
: N Edit Next file
: N Edit Previous file
: Files lists all files that are currently being opened by vim
3.3 Multi-window function
: SP "FileName" opens a new window, if Add filename, to open a new file in a new window
Otherwise represents two windows for the same file contents
CTRL+WJ Press CTRL, then press W, release all keys and press J, the cursor moves to the window below
Ctrl+wk Ibid, but the cursor moves to the window above
Ctrl+wq is actually: Q End left.
[Linux]vi