Developers who may have used vim for several years still use the up, down, left and right keys instead of h/j/k/l when moving the cursor. Indeed, hjkl is a bit anti-human and difficult to adapt to. I was completely uncomfortable at the beginning. But if you master and form muscle memory, your speed will be greatly improved.
Cursor movement
To move the cursor in normal mode, please use hjkl instead of the up, down, left and right arrow keys. Here is a good way to play games, haha, this is how I practiced. The online game address is as follows:
https://vim-adventures.com/
The first level is completed using hjkl.
Move between words
Because moving between words is more efficient than cursor movement, moving between words is a daily routine It is used more frequently in China. Here are some keys and instructions for moving between words:
wMove to the beginning of the next word
WMove to the next The whitespace character
e in the word is moved to the end of the word (note the difference between it and w)
b is the opposite of w
B is the opposite of W
The learning method is the same as above, play vim games.
Search and move between lines
In fact, the fastest way to move within a line is to search for a specified character and then quickly move to above the character. Here are some related keys and instructions:
f{char} Search backwards for the character char and move the cursor to the character.
F{char} Search forward for the character char and move the cursor to the character.
#t{char} Search for the character char and move the cursor to the character before the character.
; The location of the next character
, The location of the previous character
##Move the beginning and end of the line
The interline search mentioned above can only search the characters behind the cursor. If you search forward, you cannot complete the requirement. At this time, you need to use F to search forward or move the cursor to the beginning of the line first, and then search again.Page move
Block selection
#We know that when using the vim editor, the mouse has no effect, and you cannot use the mouse to select a character. Next we will introduce block selection. With it, combined with cursor movement, you can complete the selection of a paragraph of characters.The above is the detailed content of vim fast movement and block selection. For more information, please follow other related articles on the PHP Chinese website!