linux Vim basic operating method

  • 2020-05-07 20:46:25
  • OfStack

Recently, I have been relearning Unix with Ubuntu11.04, which I did not learn well before, but X Window of Ubuntu11.04 did not perform well under VMware7.1.4. It doesn't matter, just lay the groundwork for the command line.
Vi of Ubuntu is also not good to use, I made an Vim for learning, simply record its basic operation, spare, to provide you with a book "UNIX practical tutorial (5th edition)"
Command mode switch to text input mode:

key

function

i

Type text to the left of the cursor

I

Enter text at the beginning of the current line

a

Type text to the right of the cursor

A

Enter text at the end of the current line

o

Adds a blank line to the bottom of the current line with the cursor at the beginning of the new line

O

Adds a blank line to the current line with the cursor at the beginning of the new line

Whatever shortcut you use to enter this mode, in insert mode, you insert in front of the cursor.  

Text modification key, only applicable to command mode

key

function

x

Deletes the character specified by the cursor position

dd

Deletes the line where the cursor is located

u

Undo recent changes

U

Undo all changes made to the current status

r

Replaces 1 character in the cursor position

R

Replaces the character from the cursor position, and changes vim to the text input mode

.

Repeat the previous modification

Cursor movement key, control cursor movement in command mode.

key

function

h or [please]

Move the cursor 1 bit to the left

j or [left]

Move the cursor down 1 row

k or [write]

Move the cursor up 1 row

i or [-]

Move the cursor 1 bit to the right

$

Moves the cursor to the end of the current line

w

Move the cursor one word to the right to the beginning of the next word

b

Move the cursor one word to the left to the beginning of the previous word

e

Move the cursor to the end of the word

0

Moves the cursor to the beginning of the current line

[Enter]

Move the cursor to the beginning of the next line

[Space]

Move the cursor 1 bit to the right

[Backspace]

Move the cursor 1 bit to the left

The exit command, with the exception of the ZZ command, starts with ":" and ends with [Enter].

key

function

wq

Save the file and exit the editor

w

Save the file, but do not exit the editor

q

Exit the editor

q!

Exit the editor without saving the file

ZZ

Save the file and exit the editor

Search command

key

function

/

Search ahead for the specified string, then press n to find the next one

?

Search backwards for the specified string, then press n to find the next one

A detailed explanation of the command can be used in vim :help [command] to query online help.

The above command was used in Vi and has been tested in Vim 7.3.35.


Related articles: