Basic
There are three modes of vim:
- Navigation (navigation) mode. At this time, the letter is the next key around.
- Input mode. This is when you press the letter key to enter the letter.
- Command mode. You need to enter a ":" Colon before you enter. For example, you type: LS, which is equivalent to running a
ls
command.
Three modes of switching
The default is navigation mode. In other modes, press "ESC" to return to the navigation mode.
In navigation mode, input, and so on, a
i
o
You can enter into the input mode.
In navigation mode, the input :
can be entered into the command mode.
So, in the use of vim, we use the ESC will be used very much.
(Incidentally, when using Vim, blind play is the basis, so,, j
f
, around ctrl
, are your eyes in the hands.) Be sure to familiarize yourself with their location. )
Up or down
The reason for using these four keys is that everyone's right index finger should be placed on J. J and F are the easiest two keys to touch. So, JHKL is taken for granted to be up and down.
The next word, the last word
w
: The next word. (word)
b
: the previous word. (Backword)
So, let's remember, click on the w
equivalent of press more l
.
One screen down, one screen up.
ctrl + f
: Down one screen (f = forward)
ctrl + b
: Up one screen (b = backward)
Select multiple lines
shift + v
, and then move up and down.
Search
Search some_thing:/some_thing
Continue searching for the next:n
Search the previous one:shift + n
In the current entire file, replace (also called global substitution)
:%s/原来的字符串/新字符串/
(If a string appears multiple times in a row and wants to replace all occurrences of it, add one at the end g
, like this: :%s/原来的字符串/新字符串/g
)
Partial substitution
shift + v
Select several rows first
:s/原来的/新的字符串
Code completion
ctrl + n
: Next candidate
ctrl + p
: Previous candidate
Turn
Shen thought
Links: http://www.imooc.com/article/13269
Source: MU-Class Network
This article original published in Mu class network, reproduced please indicate the source, thank you for your cooperation!
Vim Learning Record (RPM)