The previous article introduced the four modes of Vim. This article continues with the common commands of Vim, and it is highly recommended that you open a Vim to watch and practice. Last article address: juejin.cn/post/699133…
Create a new test file and start experimenting
touch test.txt
Create a new filevim test.txt
Enter vim’s normal mode- According to the
i
Enter insert mode and enter hello - According to the
Esc
Exit insert mode - According to the
yy
Copy the current row - According to the
p
Paste what you just copied
Now that you have a test file, you can use it to start practicing the common vim commands
The following instructions are in normal mode:
Common commands related to cursor movement
The entire document
gg
: Moves to the first line of the document2gg
: moves to the second line of the documentG
: Moves to the last line of the document
A single
0
(Number 0) : Move to the beginning of the line$
: Moves to the end of the line
The word
b
: Move to the beginning of a worde
: Move to the end of the word3w
: Move to the beginning of the next third word
other
%
: moves to the matching character, default is: (){}[]
Copy and paste the common delete commands
copy
yy
: Copies the current row2yy
: Copies the current two rowsyw
(W: word) : copies a single word
paste
p
: Pastes after the current cursor
delete
dd
: Deletes the current row2dd
: Deletes the current two linesdw
: Deletes a single wordx
: Deletes a single character
Common undo and redo commands
undo
u
: Undo the last operation
redo
ctrl+r
: Redo the previous operation
Part of the commonly used commands are introduced, can be completed after learning through some operations to check, to the first newly created file as an example, perform the following operations to try:
- Move to the beginning of the file
- Move to the end of the current row
- Copy the word
- Move to the end of the file
- Paste this word
- Move to the beginning of the line
- Delete current row
The above content can be made into a simple manual, more detailed commands can be seen at the following address
A more complete query website, for reference: vim.rtorr.com/