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 vi/vim command in Linux system

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

Share

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

This article shows you how to use the vi/vim command in the Linux system, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. The difference between vi and vim:

That is, after entering the general command mode, when you press any letter (I, I, o, O, a, A, r, R), you will enter edit mode. At this point, you can edit the text.

In general command mode, enter (: /? ) any one of the three keys enters instruction command mode. In this mode, you can read, save, replace a large number of characters, leave the vi, display line numbers, and so on.

The vi editor is the standard editor for all Unix and Linux systems. It is equivalent to notepad in windows systems. It is as powerful as any latest text editor. It is an indispensable tool for us to use Linux system. Since the vi editor is exactly the same for any version of Unix and Linux systems, after learning it, you will walk freely in the world of Linux.

Vim has the ability of program editing, it can distinguish the correctness of grammar by font color, it is convenient for program design, and the editing speed is very fast.

Vim can be used as an upgraded version of vi, which can display some special information in a variety of colors.

Vim will judge the content of the file according to the file extension or the beginning information in the file, and automatically execute the syntax judgment of the program, and then display the program code and general information in color.

Many additional features have been added to vim, such as regular expression search, multi-file editing, block copying, and so on. This is a great feature for us to do some configuration file modification on Linux.

2. Vi/vim can be divided into three modes, namely, [general command mode], [edit mode], and [instruction line command mode].

[general command mode]:

Opening a file with vi goes directly into the normal command mode (that is, the default mode). In this mode, you can move the cursor, delete characters or delete the entire column to manage the contents of the file, or you can use copy and paste to process the file.

[edit mode]:

That is, after entering the general command mode, when you press any letter (I, I, o, O, a, A, r, R), you will enter edit mode. At this point, you can edit the text.

[instruction line command mode]:

In general command mode, enter (: /? ) any one of the three keys enters instruction command mode. In this mode, you can read, save, replace a large number of characters, leave the vi, display line numbers, and so on.

3. The conversion between users can be simply represented by the following figure

Introduction

Basic usage: vi+ (path) file name

Through the above command, you directly enter the general instruction mode

Press I again to enter editing mode

If you press the (Esc) key, you return to normal instruction mode.

Press the (:) key to enter instruction line command mode

Save exit: (esc +: + qw)

Exit without saving: (esc +: + Q! )

4. Various parameters and their functions

1 >, in general instruction mode

Search and replace:

Delete copy and paste

2 >, general instruction mode switch edit instruction mode

Enter insert or replace editing mode

3 >. General instruction mode toggles instruction line command mode

Instructions for storing, leaving, etc., of instruction column mode

The above is how to use the vi/vim command in the Linux system. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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