VI and VIM are both text editor, the difference is that Vim is the upgrade version of VI, it is not only compatible with all VI directives, but also some new features in it.
Vim/vi is a powerful full-screen text editor, which is the most commonly used text editor on Linux/unix, and its role is to create, edit, and display text files.
Vim/vi no menus, only commands
Vim/vi Three modes of operation:
One, Common command 1, insert command
Insert Command
Command |
Role |
A(append) |
Append text after the cursor |
A |
Append text at the end of our line |
I(insert) |
Insert text before the cursor |
I |
Start inserting text at the bank |
O |
Insert a new line under the cursor |
O |
Insert a new line on the cursor |
2. Positioning commands
position Command
Command |
Role |
h, direction left button |
Move left one character |
J, the direction of the key |
Move down one line |
k, the direction of the key |
Move up one line |
l, right Arrow |
Move one character to the right |
$ |
Move to end of line |
0 |
Move to the beginning of the line |
H(High) |
Move to upper Screen |
M(middle) |
Move to the center of the screen |
L(Low) |
Move to the bottom of the screen |
: Set Nu |
Set line number |
: Set Nonu |
Cancel line number |
Gg |
To the first line |
G |
To the last line |
NG,: N |
to Nth row |
3. Delete command
Delete command
Command |
Role |
X |
Delete the character at the cursor location |
Nx |
Delete the first n characters at the cursor location |
Dg |
Delete the content at the end of the file where the cursor is located |
D |
Delete from the cursor to the end of the line |
: n1,n2d |
Delete rows of the specified range (N1~N2) |
4. Copy and Cut commands
Copy and Cut commands
Command |
Role |
yy,Y |
Copy the current cursor in the row |
Nyy,NY |
Copy n rows from the row where the current cursor is located |
Dd |
Cuts the current cursor in the row |
Ndd |
Cuts n rows from the row where the current cursor is located |
P(paste) |
Paste below the line where the current cursor is located |
P |
Paste on the line where the current cursor is located |
5. Replacement and Revocation orders
Replace and REVOKE commands
Command |
Role |
R(replace) |
The character at which the cursor is replaced |
R |
To replace a character from where the cursor is, press ESC to end |
U(undo) |
Undo previous Action |
6. Search and Replace commands
Search and Replace commands
Command |
Role |
/string |
Searches backward for the specified string Press N to jump to specify where the next string appears Press N to jump to the specified position where the previous string occurred Ignore case when searching : Set IC |
:%s/old/new/g |
Replace the specified string with the full text (replace old with new) |
: n1,n2s/old/new/g |
Replace a specified string within a certain range (N1~N2) |
7. Save and Exit commands
Save and Exit commands
Command |
Role |
: W |
Save changes |
: w New_filename |
Save as specified file |
ZZ,: Wq |
Save changes and exit |
: q! |
Do not save changes to exit |
: wq! (Administrator root only or The owner of the file can use it) |
Save changes and exit Read-only properties of the file can be ignored |
Vim/vi Broad and profound, beginners will feel very complex and inefficient operation, but when you fully familiar with it, you will feel it is simply an artifact, using it can greatly improve the efficiency of our code code.
This is a you do not need to use the mouse, do not need to use the keypad, just need to use the large keyboard to complete a lot of complex function text editing editor, otherwise, Visual Studio will not have vim plug-in. Learning Vim is just like learning to play the piano, and once learned, the benefits are endless.
There is also a good article about Vim here, want to learn more can take a look at
http://mp.weixin.qq.com/s?__biz=MjM5OTMxMzA4NQ==&mid=209275637&idx=2&sn= 1b6e279e33a0e161ac94458808497eb2
(d) Text editor Vim/vi