Detailed explanation of the usage of common Linux commands (Part 2) ———— Text editor commands vi/vim

Detailed explanation of the usage of common Linux commands (Part 2) ———— Text editor commands vi/vim

Introduction to vi/vim

They are both multi-mode editors. The difference is that vim is an upgraded version of vi. It is not only compatible with all vi commands, but also has some new features.

1. The difference between vi and vim:

After entering the general command mode, when you press any letter such as (i, I, o, O, a, A, r, R), you will enter the editing mode. You can now edit the text.

In the general command mode, input any of the three keys (:/?) to enter the command mode. In this mode, you can read, save, replace a large number of characters, exit vi, display line numbers, etc.

  1. The vi editor is the standard editor for all Unix and Linux systems. It is equivalent to Notepad in Windows systems, and its power is as good as any of the latest text editors. 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, once you learn it, you will have no obstacles in the Linux world.
  2. Vim has the ability to edit programs. It can use font color to identify the correctness of syntax, which is convenient for program design and the editing speed is quite fast.
  3. Vim can be regarded as an upgraded version of vi. It can display some special information in multiple colors.
  4. Vim will judge the content of the file based on the file extension or the beginning information in the file and automatically execute the syntax judgment formula of the program, and then display the program code and general information in color.
  5. Many additional features have been added to vim, such as support for regular expression search, multi-file editing, block copying, and more. This is a great feature for us to modify some configuration files on Linux.

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

【General command mode】:

Opening a file with vi directly enters the general command mode (that is, the default mode). In this mode, you can move the cursor, delete characters or entire columns to manage file contents, and use copy and paste to process files.

【Edit Mode】:

After entering the general command mode, when you press any letter such as (i, I, o, O, a, A, r, R), you will enter the editing mode. You can now edit the text.

【Command line mode】:

In the general command mode, input any of the three keys (:/?) to enter the command mode. In this mode, you can read, save, replace a large number of characters, exit vi, display line numbers, etc.

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

introduce

  1. Basic usage: vi+(path) file name
  2. The above command directly enters the general command mode
  3. Press i again to enter edit mode
  4. If you press the (Esc) key, you will return to the normal command mode.
  5. Press the (:) key to enter command line mode
  6. Save and exit: (esc + : + qw)
  7. Exit without saving: (esc + : + q!)

4. Various parameters and their functions

1>, General command mode

Search and Replace:

Delete Copy and Paste

2>, General command mode switches to edit command mode

Enter insert or replace edit mode

3>、General command mode switch command line command mode

Instructions such as save and exit in command queue mode

The above is the editor's introduction to the usage of common Linux commands (Part 2) - Detailed explanation and integration of text editor commands vi/vim. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Summary of Linux vi command knowledge points and usage
  • Linux Vim Practical Commands Explained
  • Linux common text processing commands and vim text editor
  • Detailed explanation of Docker service command (summary)
  • Detailed explanation of running multiple commands in Docker container (supervisor)
  • Detailed examples of using macro commands in Vim
  • Vim command collection
  • Common commands for using the text editor vi in ​​Linux
  • Detailed summary of Linux file editing command vi
  • Summary of commonly used commands of Vim editor
  • Recover the missing "View in Browser" command in Visual Studio 2017
  • Detailed explanation of the differences and commands between vi and vim
  • Linux vim editing command mode
  • Complete list of Vim split screen commands
  • vim command list
  • How to turn Vim into a Python IDE with two commands
  • Detailed explanation of vi commands in Linux
  • The most complete collection of VI commands and shortcut keys. Recommended collection

<<:  React hooks pros and cons

>>:  How to install mysql on centos and set up remote access

Recommend

JavaScript to display hidden form text

This article shares the specific code of JavaScri...

Solve the problem that Docker must use sudo operations

The steps are as follows 1. Create a docker group...

CSS3 implementation example of rotating only the background image 180 degrees

1. Mental Journey When I was writing the cockpit ...

MySQL database JDBC programming (Java connects to MySQL)

Table of contents 1. Basic conditions for databas...

What are the advantages of MySQL MGR?

MGR (MySQL Group Replication) is a new feature ad...

Solution to data duplication when using limit+order by in MySql paging

Table of contents summary Problem Description Ana...

Summary of problems that may occur when using JDBC to connect to Mysql database

First, clarify a few concepts: JDBC: Java databas...

A brief discussion on the solution to excessive data in ElementUI el-select

Table of contents 1. Scenario Description 2. Solu...

25 Vue Tips You Must Know

Table of contents 1. Limit props to type lists 2....

How to use dynamic parameters and calculated properties in Vue

1. Dynamic parameters Starting from 2.6.0, you ca...

Solution to Nginx 500 Internal Server Error

Today, when I was using Nginx, a 500 error occurr...

JavaScript to implement click to switch verification code and verification

This article shares the specific code of JavaScri...

JavaScript implements circular progress bar effect

This article example shares the specific code of ...

Detailed explanation of rpm installation in mysql

View installation and uninstallation # View rpm -...