Ubuntu does not come with Vim by default, you need to install it yourself:

sudo  apt install vimCopy the code

Vim’s working mode

  • Command mode
  • Edit mode
  • At the end of the line mode

Description:

Vim opens the file into command mode

The effect of working mode is shown below:





Note:

The switch between edit mode and last line mode cannot be performed directly, but must be completed through command mode.

Cursor movement in VIm (command line mode)

H moving to the left

J moving down

K moves up

L goes to the right

Common vim commands (command line mode)

The command instructions
yy Copies the line where the cursor is
p/P Paste the line below the cursor/paste the line above
dd Deletes/cuts the current line
V According to the line selected
u undo
ctrl+r The undo
>> The right indent
<< The indentation to the left
:/ Search content Search for specified content
:%s/ what to replace/what to replace /g Global replacement
: Number of start lines, number of end lines s/ Contents to be replaced/contents to be replaced /g Partial replacement
. Repeat the previous command operation
G Let’s go back to the last line
gg Let’s go back to the first line
Digital + G Return to specified line
shift+6 Returns to the beginning of the current line
shift+4 Return to the end of the current row
ctr+f The next screen
ctr+b On a screen

Vim split screen operation

Vim -On Open multiple files vertically CTRL + WW switch between files

Vim-on Multiple file names open multiple files horizontally CTRL + WW files toggle between them

V with the entire row selected, a y can be copied. V is selected locally and y is copied.

The value of vGU is lowercase

Select uppercase letters in vgU

At the end of the line mode

  • save

    • W to save

    • Q exit

    • X Save exit

    • ! Forced out of

  • search

    • /str n

  • replace

    • %s/old_str/new_str/g Global replacement in file

    • 1,10s/old_str/new-str/g 1 to 10 lines global replacement

Ps: You can also press shift+ZZ to save the Settings and exit.