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

How to use a game controller in CocosCreator

Table of contents 1. Scene layout 2. Add a handle...

Analyze the usage and principles of Vue's provide and inject

First, let's talk about why we use provide/in...

Example of Html shielding right-click menu and left-click typing function

Disable right-click menu <body oncontextmenu=s...

Example of javascript bubble sort

Table of contents 1. What is Bubble Sort 2. Give ...

JavaScript color viewer

This article example shares the specific code of ...

Detailed explanation of the use of Element el-button button component

1. Background Buttons are very commonly used, and...

Tutorial on building svn server with docker

SVN is the abbreviation of subversion, an open so...

The process of using vxe-table to make editable tables in vue

There is a table in the project that needs to be ...

Example analysis of the principle and solution of MySQL sliding order problem

This article uses examples to explain the princip...

Vue implements the drag and drop sorting function of the page div box

vue implements the drag and drop sorting function...

How to use ss command instead of netstat in Linux operation and maintenance

Preface When operating and managing Linux servers...

How to install Composer in Linux

1. Download the installation script - composer-se...

Detailed examples of the difference between methods watch and computed in Vue.js

Table of contents Preface introduce 1. Mechanism ...

Understand the use of CSS3's all attribute

1. Compatibility As shown below: The compatibilit...

javascript realizes 10-second countdown for payment

This article shares the specific code of javascri...