Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use the vim Editor to move and select blocks

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

This article is about the movement and block selection of vim editors. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

Developers who may have been using vim for several years still use the upper and lower 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 unaccustomed to it at the beginning. But if you are adept at forming muscle memory, it will greatly increase your speed.

Cursor movement

To move the cursor in normal mode, use hjkl instead of the left and right arrow keys. Here's a good way to play games. Haha, that's how I practiced. The online game address is as follows:

Https://vim-adventures.com/

The first level is accomplished by using hjkl.

Move between words

Because moving between words is more efficient than cursor movement, moving between words is more commonly used on a daily basis. Here are some keys and instructions to move between words:

W move to the beginning of the next word

W move to the white space of the next word

E moves to the end of the word (notice the difference between him and w)

B is the opposite of w

B is the opposite of W

Learning method, or the same as above, to play vim games.

Interline search movement

In fact, the fastest way to move within a line is to search for a specified character and then quickly move to that character. Here are some related buttons and instructions:

F {char} search backwards for the character char and move the cursor over it.

F {char} searches forward for the character char and moves the cursor over it.

T {char} searches for the character char and moves the cursor over the character before it.

Where the next character is located

Where the previous character is located

Movement at the beginning and end of a line

The interline search mentioned above can only search for the characters behind the cursor, and the requirement cannot be completed if you search forward. At this point, you need to use F to search forward or move with the beginning of the line, first move the cursor to the beginning of the line, and then search.

0 the number 0 moves the cursor to the beginning of the line

Move the cursor to the end of the line

Here's a tip: you can move to a non-white space character at the beginning of a line using 0roomw and after the last character using $b.

Page movement

Gg moves to the first line

G moves to trailing line

NG moves to the specified line

Top / middle / bottom of the H/M/L view

Turn the page on ctrl+u

Turn the page under ctrl+f

Zz centers the cursor

Block selection

We know that with the vim editor, the mouse is useless, and you can't use the mouse to select a character. Next we introduce the block selection, with it combined with cursor movement, you can complete the selection of a section of characters.

V Select multiple characters

V Select Row

Ctrl+v block selection

Y copy

D Delete

P paste

On the vim editor movement and block selection methods to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report