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

How to use vim Editor

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article will give you a detailed introduction to the use of vim editor, the detailed steps are clear, the details are properly handled, I hope you have gained something through this article, let's first take a look at the introduction of vim editor:

Unlike normal editors, vim defaults to normal mode after it is opened, and text cannot be edited at this time. This step persuaded many users to retreat. Beginners realized that they couldn't edit files, and thought,"What a rubbish editor!" In addition, it is not the use of the mouse, not through the mouse to select text and other operations. Close these two points, it is estimated that the vast majority of beginners scared off!

First, let's talk about what vim mode is. There are three vim modes (some tutorials say four, and block selection is also used as a mode): normal mode, insert mode, and command line mode. Here is a diagram to illustrate the relationship between these three:

enter edit mode

When we enter the vim editor, the default is normal mode, at this time, if you want to enter some characters, you need to enter the insert mode first. To enter insert mode, press the following letters, which have different meanings:

a Insert after cursor

A inserted at the end of the current line

i Insert before cursor

I Insert at the beginning of the current line

o Insert a new line below

O Insert a new line above

After entering insert mode, you can edit text freely. To return to normal mode, simply press esc.

save and exit

As for command-line mode, we'll only talk about saving and exiting text today. We'll leave the rest, such as search and replace, for later. Common save exit commands are as follows:

:w Save files

:wq Save and exit

:q Exit

:q! Force exit without saving files

:w filename Save as

execute shell commands

There is a very useful trick in vim command-line mode that is often used when writing shell scripts. The syntax of the command is as follows:

:! [command]

There are two ways to revert from command-line mode to normal mode. The first removes commands from the command line, and the second presses esc twice in a row.

Of course, I'm not here to discourage you from learning vim, but to encourage more people to join the editor. Here are two tips for learning vim:

Use hjkl instead of up, down, left and right keys

Practice more, which can produce skill, let oneself form muscle memory

After reading the above, do you have any further understanding of how to use vim editor? If you still want to learn more skills or want to know more about related content, welcome to pay attention to the industry information channel, thank you for reading.

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