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

Introduction to common operations of VIM editor for Linux system

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

Share

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

This article mainly explains the "Linux system VIM editor common operation introduction", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "Linux system VIM editor common operation introduction" bar!

Introduction to common operations of VIM editor for Linux system

VIM editor is one of the necessary skills on the road of learning linux, and it is also a basic command that must be learned. for beginners, many practical functions are not very clear, so today let's sum up some practical functions and the usage of shortcut keys.

Vim filename Editing a file (this file will be created if it does not exist)

[root@Centos data] # vim newfile.txt

~ "newfile.txt" [New File]

If it is a new file, the file name is displayed at the bottom and marked as a new file

VIM mode: normal mode, insert mode, bottom line mode

Compile a file with the vim file name, and you are in normal mode

Enter I in normal mode (note lowercase) to enter insert mode

Enter in normal mode: execute command, / forward lookup,? Reverse search enters bottom line mode and press Q to exit

VIM normal mode

. Repeat the previous command

X Delete the character at the cursor position

D cut from the cursor

Dd cuts the line where the cursor is located (saved in a temporary buffer)

Ndd starts at the current line and cuts n lines from top to bottom

P put the contents of the buffer below the current line

After executing dd on the basis of the above figure, the result of p execution is as follows

Options Indexes

AllowOverride None

Order allow,deny

Allow from all

Np executes p command n times

Execute 3p after using the dd command. The result is as follows

Options Indexes

AllowOverride None

Order allow,deny

Allow from all

P places the contents of the buffer above the current line

Y copy from the cursor

Yy copies the current line (saved in buffer)

This command differs from dd in that it retains the original line after execution, while dd does not

Nyy starts at the current line and copies n lines from top to bottom

U undo the last operation

On the basis of the above operation, you can execute multiple u command operations to return to the original state.

Press u twice to return directly to the original state.

Options Indexes

AllowOverride None

Order allow,deny

Allow from all

ZZ save exit

The h cursor moves one grid to the left

L the cursor moves one grid to the right

J move the cursor down one grid

The K cursor moves up one grid.

0 (number 0) move the cursor to the beginning of the current line

The home key also has this function

Move the cursor to the end of the current line

The end key also has this function

The e cursor moves to the end of the next word

W cursor moves to the beginning of the next word

* move to the next character that is the same as the character of the cursor

# move to the previous character same as the character where the cursor is located

Move the gg cursor to the beginning of the first line of the file

The G cursor moves to the beginning of the last line of the file

Enter and move to the beginning of the next line

Instance operation

Options Indexes plugins 10 html here

AllowOverride None

Execute 10ihtml and then press ESC to exit.

Options Indexeshtmlhtmlhtmlhtmlhtmlhtmlhtmlhtmlhtmlhtml

AllowOverride None

Bottom line mode

: set nu displays the line number

Options Indexes

AllowOverride None

Order allow,deny

Allow from all

The result of set nu execution is as follows

five

6 Options Indexes

7 AllowOverride None

8 Order allow,deny

9 Allow from all

ten

S / w/h/ replaces all strings that match w with h

: = display the total number of rows

: n move the cursor to the beginning of the nth line

Thank you for your reading, the above is the "introduction to the common operation of the VIM editor of the Linux system". After the study of this article, I believe you have a deeper understanding of the common operation of the VIM editor of the Linux system, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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