vim editor under liunx


vi editor is all Unix and Linux standard editor in the system, he is equivalent to windows Notepad system, as its latest powerful not inferior to any text editor. He is our use Linux systems indispensable tool. Since any version of Unix and Linux systems, vi editor is exactly the same, after learning it, you will be unimpeded in the Linux world.
vim has the ability to program editing, font color discrimination may grammatical correctness, easy programming;
because the program is simple, editor at a fairly fast.
vim can be used as an upgraded version of vi, he can use a variety of colors way to show some special information.
vim syntax will automatically determines the execution of the program according to the file type extension, or at the beginning of the information in the file, determining contents of the file, and then to display the color information of the program code in general.
vim it added a lot of extra features, such as support for regular expression search, multi-file editor, block copy and so on. This is a great feature for when we modify some configuration files work on Linux.

  

           

                                                                       

General pattern:
to open a vi file directly into the general pattern of the (this is the default mode). In this mode, you can use the arrow keys to move the cursor, you can use the Delete character or delete the entire line to process the file content, you can also use copy and paste to handle your data files.

Editing mode:
in the general mode can delete, copy, and paste operations etc., but can not edit the contents of the file, only when you press the [i, I, o, O,], etc. You will enter edit mode after any letter. This time the bottom left of the screen will appear the words [INSERT or REPLACE], in which case it can be edited. And if you want to return to normal mode, you have to press [Esc] to exit editing mode.

Command line mode:
Enter [:? /] In any of the three, you can move the cursor to the bottom line that the most. In this mode, you can offer to find, read, save, replace characters, leave vi, display line numbers, etc. of the action is done in this mode!

 

General description Mode buttons available
to move the cursor
[h, j, k, l}, respectively, to control the cursor left, under, on the right of a cell
by screen [ctrl + b] to "back" a moving
press [ctrl + f ] screen to move "forward" a

[N <space>] move the cursor to the right n characters
[] Home moves the character to the front of the line: 0 digital, but not with the number on the keypad
[End] moves to the last character on the line of the plane : $, I tested it seems not
[w] cursor jumps to the beginning of the next word
[e] cursor jumps to the next word suffix

[H] move the cursor to the first character of the top of the row of the screen
[M] move the cursor to the first character in the middle of the screen in the row
[L] move the cursor to the bottom of this screen that the first row a character

[G] is moved to the last line of
[nG] moves to the n-th row of this file (can be used with: set nu)
[] gg moves to the first line of the file, corresponding to 1G
[n <Enter>] Cursor downward movement of the line n

Find and replace
[/ word] to the cursor down to find a name for the word string
[?] Looking up the word the cursor to a name string of the word
[n] to find a representative of the former operation is repeated
[N] and n immediately On the contrary, [it is] to a reverse lookup action forward

[: N1, n2s / word1 / word2 / g] n1 and n2 are numbers, to find the string word1 between the first row n1 and n2, and the character string is replaced word2

[: 1, $ s / word1 / word2 / g ] Find the last row from the first row to the string word1, word2 and replace the string
[: 1, $ s / word1 / word2 / gc ] from the first row the last line to find word1 string and the string is replaced word2, and prompts the user to confirm whether or replaced before the replacement

Delete, copy and paste

[X] to delete a character backward (equivalent to [del] key)
[X] to delete a character forward (equivalent to [backspace] key)
[nx] n consecutive delete characters backwards

[Dd] Delete cursor line
[Delete] ndd down cursor line n
[] d1G cursor to delete all the data of the first row to the row
[dG] Remove the cursor to the last line of all the data

[D $] to delete the cursor position to the last character of the line
[d0] to delete the cursor position to the previous character most of the line

[Yy] copy the line cursor
[copy] nyy down cursor column n

] [Y1G copy all the cursor line data of the first row
[copy] yG cursor to the last row all data

[Y0] copies all the data that character under the cursor to the first of trekking
[] y $ Copy the character under the cursor to the end of the trekking all the data

[P] the copied data is pasted to the cursor next line
[P] was attached to the cursor on the line

[U] before a recovery operation
[Ctrl + r] redo last action

[.] Before the operation is repeated a

General mode to the edit mode described buttons available
[i, I] into edit mode:
I is the current cursor from [insert]
I is the current in the [first non-space character is inserted at the beginning of row]
 
[a , a] into edit mode (the insert mODE):
a is [from a character at the current cursor initial insertion]
a is [inserted starting from the last character of the line cursor]

[O, O] into edit mode:
O [insert a new row to the next row at the current cursor]
O is the current row in which the cursor is to insert a new row

[R, R] enter replace mode:
r will replace it once a character under the cursor
R will always replace the text cursor until you press ESC so far;

[Esc] to exit Edit mode and return to normal mode

General mode button to switch to the command line mode available Description
[: w] to save the edited contents
[:! W] forced to write to the file, but you do with the file permissions
[: q To leave vi
[: q!] I do not want to save the changes forced to leave
[: wq save] leave
[: x] leave after saving
[ZZ] If the file does not modifier, leave is not saved, if the file has been changed, then left after saving

[: W filename] to save the edited data file to another (similar to the save)
[: r filename] In the data editing, the data read another file. [Filename] is about the content of this document is added to the line behind the cursor.

[: N1, n2 w filename] to save the contents of n1 n2 into the file filename.
[:! Command] to temporarily leave the vi command line mode execution command displays the results! [For example:! Ls / home] to look at them in vi / home under ls output to file information!

[: Set nu show line numbers]
[: set nonu] and set nu contrast, is canceled

 

simply put:

: wq line mode, save and exit
: q line mode, exit
: q line mode without saving, force-quit!
(c) an input mode (operating in command mode)

i cursor position beginning from the front insert
I is inserted into the current line
a start position of the cursor from the rear input
A is inserted in the current line
o a new row below the row in the cursor and the input mode
O in the top row of the current insertion
(IV) move the cursor (operating in command mode)

gg to the file of the first row
G to the last line of the file (the Shift + G)
^ first non-space row
0 the first row (number 0)
$ end of line
(v) copy and paste (operating in command mode)

yy Copy whole line is copied as three rows 3yy
yw copy the current cursor to end of word content
p paste
(f) Delete

dd Delete cursor line
dw delete a word
x cursor to delete characters
u undo the last operation
s Alternatively
ctrl + r revoked u
(vii) block operation

v block selection
ctrl + v to select blocks
(eight) Find

/ Command mode, type: / search forward
command mode, enter:?? Back search
n find down
N find up

 

Guess you like

Origin www.cnblogs.com/qiantan/p/11463281.html