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

What are the basic operating methods of vim

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly explains "what are the basic operation methods of vim". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "what are the basic operation methods of vim"!

Text editing (based on IMX6 ULA Terminator development board) is the most commonly used tool, we can use Notepad under the Windows system, or some other more powerful text compilation software, such as UltraEdit. Ubuntu comes with a text editor by default: Gedit, which is a windowed editor.

device. Compared to Gedit text editor, we use the most command-line editor: vim. The vim editor is on the terminal.

Mode operation, the default Ubuntu system does not install vim, we can manually install vim editor through the apt-get command, first of all

We enter the command "sudo apt-get install vim" in the terminal, and then enter. During the installation process, we will be prompted whether to continue the installation.

Enter y and continue installation. The installation process is as shown below:

Vim has three modes of operation: command mode, insert mode, and bottom line mode. By switching between different modes, different functions can be accomplished.

Take editing a document as an example to learn how to use vim. First open the terminal and enter the command "sudo vi myfile", as shown in the following figure:

vim open myfile file first in command line mode, at this time we are not able to enter text in the terminal, so we need to switch to insert

Enter mode, we can enter any of the following letters in the terminal to enter the insertion mode:

a //Change to insert mode after the current cursor character

i //Go to insert mode before the character where the cursor is currently located

o //Create a new line below the current cursor line and switch to insert mode

O //Create a new line above the current cursor line and switch to insert mode

s //Delete cursor character

r //Replace character at cursor

The most common thing we use is to enter the letter "a". We press the "a" button on the keyboard in the above picture, and you can see that there will be "plug" in the lower left corner of the terminal.

The prompt of "Enter" indicates that the current insertion mode is in, as shown in the following figure:

Entering the insert mode, we can enter the text as shown below:

After the text is entered, we need to save the text. First press the keyboard ESC key to exit the current insertion mode and return to the command line.

Mode, as shown in the following figure:

In the image above we can see that the "insert" character in the lower left corner is gone, indicating that we are now in command line mode, and then I

We enter the ":" key (Shift+; key combination) in the terminal to enter the bottom row mode, and we will see a ":" colon in the lower left corner of the terminal.

As shown below:

In the bottom row mode of the above figure, the commonly used commands are as follows:

Q to quit

w Save changes

q! Exit without saving changes

We can save the text entered above by typing "wq" and then pressing Enter to complete the document save and exit vim, as shown in the following figure:

After exiting the vim text editor, we can use the cat command to view the contents of the myfile we just created, as shown below:

As you can see from the above figure, the contents of the myfile are what we entered with the vim editor, so far we have completely used vim

Text editor enables the creation, editing, and saving of documents.

Sometimes we use keyword search function in the process of editing files, vim editor also provides very convenient keyword search function

Yes, let's learn the keyword search function of vim below. First, enter "vim myfile" to open the myfile file created earlier, as follows

Figure shows:

In the above image we open the file myfile, vim is in command-line mode, we enter the "/" character in the terminal to make vim enter the backplane mode

As shown below:

In the above figure, we enter the keyword to be queried when entering the bottom row mode, for example, we query the keyword "topeet", as shown in the following figure.

Show:

After typing in the keyword "topeet," we press enter, vim will go to the file to find the first position where the keyword appears,

After searching, the cursor will be positioned at the position of the keyword, as shown in the following figure:

At this point, I believe that everyone has a deeper understanding of "what are the basic operation methods of vim", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

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

Internet Technology

Wechat

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

12
Report