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

Introduction of Mapping function in vim Editor

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

Share

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

What is mapping?

Mapping can be understood as setting shortcut keys, which allows you to replace more and more keys with a small number of keys that are easy to press.

When to use mapping

If you have one or more of the following troubles, you can use mapping.

Dissatisfied with the current button

Want to set some keyboard shortcuts to improve editing speed

Want to combine some buttons to complete the new requirements

Classification of mappings

We know that vim has a variety of modes, and corresponding mappings include nmap (normal mapping), imap (insert mapping), and vmap (block selection mapping).

Let's select several cases to talk about these three mappings.

General mapping

"use F1 to toggle display line number nmap: set nu! nu?

The CR here means enter.

Insert Mapping

"use jj instead of the ESC key to return from insert mode to normal mode imap jj `^

We usually use jj instead of the ESC key to quickly switch from insert mode to normal mode.

"delete the character imap imap lxi forward and backward in insert mode

Where c represents the ctrl key, in insert mode, use ctrl+b to delete one character backward, and ctrl+d to delete one character forward.

Block pattern mapping

In general, we often increase or decrease the indentation of multi-line text. As mentioned in the previous article, this requirement can be achieved through block selection combined with the command line, or through macros. Today, after learning about mapping, you can use a simpler method to implement the requirements.

Vmap

< >

Gv

Now, if we want to indent multiple lines, just select them and press > or

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