当前位置:网站首页>VIM common commands

VIM common commands

2022-06-11 07:32:00 m0_ fifty-two million twelve thousand six hundred and fifty-six

vim command

1. Command mode

Text operation

yy: Copy the line where the cursor is 
nyy: Copy n Row content , Start with the line where the current cursor is 
dd: Deletes the line where the cursor is located 
ndd: Delete n Row content , Start with the line where the cursor is 
p: Paste on the next line of the cursor 
dd->p: Cutting function 
np: Paste n Time 
u: Undo the last action 
x,nx: Delete the content of the text where the cursor is located    From the left -> Right 
shift+x: Delete the content of the text where the cursor is located    From the right -> Left 
shift+~: Switch the case of the text where the cursor is located 
r: Replace a character , The character on which the cursor is located , Support nr
shift+r: Replace mode , Direct replacement of multiple content .
h,j,k,l: Move the cursor to the left , Next , On , Move right 

Cursor positioning

gg: Position the cursor at the beginning of the file 
G: Position the cursor at the end of the file 
nG: Position the cursor on any line 
shift+4: Position the cursor at the end of the current line , Anchor point 
shift+6: Position the cursor at the beginning of the current line , Anchor point 
b,w: Move forward or backward according to the word 
nb,nw: according to n Move a word forward or backward 

Bottom line mode

set nu: Call out the line number 
set nonu: Cancel the line Numbers 
vs  file name : Multi file operation    ctrl+w+w: Multi file cursor switch file 
w: preservation 
q: sign out 
!: mandatory 

ordinary vim To configure

The location of the configuration file

  • In the catalog /etc/ below , A name is vimrc The file of , This is common in the system vim The configuration file , It works for all users .

  • And in each user's home directory , You can create your own private configuration file , Name it :“.vimrc”. for example ,/root Under the table of contents , Usually there is already a .vimrc file , If it doesn't exist , It was created. .

  • Switch users to be their own execution su , Enter your home working directory , perform cd ~

  • Open your own directory .vimrc file , perform vim .vimrc

Common configuration options , For testing

  • Set syntax highlighting :syntax on

  • According to the line Numbers :set nu

  • Set the number of indented spaces to 4:set shiftwidth=4

A direct configuration vim Methods ( Note only applies to centos7)

 Direct operation :curl -sLf https://gitee.com/HGtz2222/VimForCpp/raw/master/install.sh -o ./install.sh && bash ./install.sh

原网站

版权声明
本文为[m0_ fifty-two million twelve thousand six hundred and fifty-six]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020519521045.html