The usage of vim in Linux

Time:2021-5-13

VIM is the most famous text / code editor on Linux system and an enhanced version of the early VI editor, while GVIM is its Windows version. Its biggest feature is the complete use of keyboard commands for editing, without the mouse operation, although it makes entry difficult, but after the start of the keyboard flow of a variety of clever combination operation can bring a very significant efficiency improvement.

Some formats of vim commands

1:vim xxx

Open a VIM file named XXX directly. If not, create a new one directly. The default cursor is defined to the first line

2:vim + xxx

Open the cursor and define to the last line

3:vim +num xxx

Open the cursor definition to line num

4:vim +/name xxx

Open the cursor, the cursor appears in the line of XXX text where name appears for the first time, and press the letter N to switch back and forth between the lines where name appears

5:vim xxx yyy zzz

Open three VIM files at a time, and open XXX by default. In the bottom line mode, enter: n to switch back and forth between these files. Enter: prev or: n to switch to the previous one

Common commands in bottom line mode of vim

: W save

: Q exit

:! Enforcement

: LS lists all open files

: nswitch to the next file

: n or: prev switch to the previous file

: position the numeric cursor to the num line quickly

/The XXX cursor searches backward for a XXX string

? The XXX cursor searches forward to the first XXX string

Common instructions written in command mode in VIM

H J K L cursor moves left down, up and right

CTRL + F page down

CTRL + B page up

CTRL + d turn down half page

CTRL + U turn up half page

DD delete current line

YY copy current line

P paste to the next line of the current line

The P station is on the previous line of the current line

O open a new line next to the current line and switch to input mode

The above is the usage of vim in Linux introduced by Xiaobian. I hope it can help you. If you have any questions, please leave me a message and Xiaobian will reply you in time. Thank you very much for your support to developer!