Linux - hands-on finishing the Vim editor

Vim Introduction

Vim is a powerful full-screen text editor, it is linux, Unix most commonly used text editor that can be used to create, edit, display text files. Vim is no menu, only the command!

Vim three modes

Command mode, insert mode, edit mode.

Vim's insert command

1, a - is inserted after the character cursor 
2, A - is inserted in line position the cursor 
3, i - is inserted before the character cursor 
4, I - the first insertion cursor line 
5, o - the cursor insert a new line 
6, O - insert a new row on the cursor

Vim positioning command

1, [: set nu] set the line number 
2, [: set nonu] to cancel the line number 
3, [gg] move the cursor to the first line 
4, [G] move the cursor to the last line 
5, to move the cursor [nG] 
6 , [$] move the cursor to the end of the line 
7, [0] move the cursor to the beginning

Vim Delete command

1, x - the character position cursor to delete 
2, nx - after a deletion at the cursor n characters 
3, dd - delete the cursor line 
4, ndd - delete the cursor n rows, row 
5, dG - Delete cursor everything between the end of the line to the file 
6, D - delete from the cursor location to the end of the line 
7, [: n1, n2d] - delete the specified line range

Vim Copy and Paste commands

1, yy - copy current line 
2, nyy - copy current line n below the line 
3, dd - the current line 
4, ndd - Cut the current line n line 
5, p - paste the contents of the cursor to the upper row 
6 , P - paste the contents of the line where the cursor below

Vim replace and cancel the command

1, r - replace the character at the cursor 
2, R - began to replace the character at the cursor location, press the ESC key operation ends 
3, u - cancel the previous step

Vim search and search and replace command

1, [/ string] specified search string, to ignore case search, you can [: set ic], and then search 
2 [n] key when the character you have to search a lot, want to continue to look at other , can view it downwardly press n 
3, [:% s / old / new / g ] replace the specified text characters 
4, [: n1, n2s / old / new / g ] in the lines specified string specified range

Vim save and exit the command

1, [: w] to save the modification 
2, [: w new_filename] file as a new file 
3 [: wq] to save changes to exit 
4, [ZZ] shortcut keys, save the changes and exit 
5. [: q!] Does not save changes and exit 
6, [:! wq] to save changes and exit (file owner and root can use this command, usually for readonly file)

Vim tips

1, introducing results of the command [:! R & lt Syntax 
2, define shortcut keys: [map shortcut key activation commands], such as the map ^ the PI # <the ESC>, map ^ B 0x 
. 3, continuous line comments: [: N1, n2s / ^ / # / g] [: n1, n2s / ^ # // g ] [: n1, n2s / ^ \ / \ // g ] 
4, replace: [ab myMail [email protected]]
Published 59 original articles · won praise 2 · Views 5583

Guess you like

Origin blog.csdn.net/LDR1109/article/details/101207477