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

Vim text editor practical information sharing

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

Share

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

Introduction to the use of vim

When it comes to vim, we have to mention that vi,vi is the standard editor for all Unix and linux systems, while Vim is a famous powerful and highly customizable text editor similar to vi, which improves and adds a lot of features based on Vi. VIM is free software. Vim is generally regarded as the best Vi-like editor.

Vim, like vi, is a full-screen text editor with no menus, only commands. You can perform many text operations, such as output, delete, find, replace, block operations, and so on, and users can customize them according to their own needs, which other editing programs do not have. It is not a typesetting program. It does not compose fonts, formatting, paragraphs, and other attributes like MS Word or WPS.

Why use vim?

There are many text editors under linux, including vi and vim as well as emacs, pico, nano, joe and so on. These tools all have their own points, but there are a few points that other editing tools cannot match.

1 all Unix-like systems have built-in vi, other editing tools are not necessarily, and vim is equivalent to the upgraded version of vi

2 the editing interfaces of many software will call vi, such as crontab, edquota, etc.

3 vim has the ability of program editing, which can actively identify the correctness of syntax by font color, which is convenient for code writing.

4 the program is simple and the editing speed is very fast.

This is the end of the introduction. Let's take a look at the basic usage.

II. Basic use

Because vi/vim is a full-screen text editor, it works in three modes: command mode, input mode, and last line mode. You can switch from command mode to input mode and last line mode respectively, or from last line mode or input mode to command mode, but you cannot switch between input mode and last line mode.

The first: command mode, when I use the "vim myfile" command to open myfile this file is in command mode, the lower left corner of the screen is the file name (myfile), 1L means that the file has 1 line, 26C means that the file has 26 characters. In this mode, users can enter commands to save files, move the cursor, delete characters, undo commands and repeat commands, as well as set up the editing environment.

This is the command mode.~ ~ indicates no content "myfile" 1L 26C 1pr 25 all

The second kind: insert mode, also known as input mode. In input mode, the word INSERT appears at the bottom left of the screen. In the input state, the user can enter the contents of the text.

This is the command mode.~ ~ ~ ~-- insert-- 1pl 25 all

The third kind: the last line mode. Just enter the command ":" in command mode to enter the last line mode. In the last line mode, you can save the file, exit vi, find and replace, and so on.

This is the command mode.~ ~ ~ ~: Q!

After the introduction of the three modes, let's take a look at the use of vim, in which we will explain the use of vim according to the three modes.

Command mode

Ctrl+f the next page, equivalent to the pagedown on the keyboard

The previous page of ctrl+b is equivalent to the pageup on the keyboard

0 move the cursor to the beginning of the line

Move the cursor to the end of the line

The G cursor moves to the last line of the file

Move the gg cursor to the first line of the file

N n is a number, move the cursor down n lines

/ word word is the keyword, with the cursor as the starting point, search backward for the specified keyword

Word searches forward for the specified keyword with the cursor as the starting point

/ word and? word can specify the next or previous one using n _ word during the search.

Dd deletes the line of the cursor

Yy copy the line of the cursor

Nyy n is a number, starting with the cursor, copy n lines backward

Paste the copied content under (p) or above (P) on the line where the cursor is located.

U undo operation

Enter input mode from command mode

An enter data from behind the cursor, and the data behind the cursor moves backward with the increased data.

I insert data in front of the cursor, and the data behind the cursor moves backward with the new data.

O add a new line under the line of the cursor and enter input mode.

From command mode to last line mode

W save

: w! Force save, used when the file is read-only

: Q do not save exit

: q! Force exit without saving

Wq save exit

: wq! Force save exit

We will stop here to introduce the basic functions of vim. Let's take a look at what additional functions there are.

Third, extra function v character selection, select the place where the cursor passes V select the line over which the cursor passes [Ctrl] + v block select y copy the selected part d delete the selected part p paste the part just copied to the location of the cursor IV. Precautions in use

Since individual versions of linux install vi by default, you need to install additional vim software packages. We will explain how to install the software packages later. In addition, vim cannot enter Chinese under the character interface, while whether you can enter Chinese under the graphical interface depends on whether the Chinese input method is installed in the system.

Summary

In this lesson, we introduced linux's text editor vim, which is a very powerful text editing software, we only learned its common functions, more functions need to be found constantly in daily use, constantly familiar with the content of this lesson is here, thank you!

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