当前位置:网站首页>VIM text editor

VIM text editor

2022-07-23 07:14:00 Xuanxue closed disciple

This article is about vim A record summary after learning , Most of them are about some noteworthy or common points , In detail vim I can't see instructions waiting here , There are many online , It is suggested that everyone be active Google. If the text is wrong , Hope to put forward in the comments , I will correct it in time , thank !

1、vim What are the main modes

  1. Command line mode
  2. Text insertion mode
  3. Bottom line mode

2、vim test.sh Which mode is the first to enter after

Just entered vim After being in Command line mode

3、 Mode switch

There are generally three ways to switch from command line mode to text insertion mode , The text insertion mode and then switch back to the command line mode directly ESC Just quit ( Don't knock one word at a time , I draw a picture directly , It's also clearer to see in this way )

 Please add a picture description

4、 sign out vim And save

This needs to be switched to Bottom line mode To operate . If you are currently in text insertion mode , Then you first need to switch the current mode to Command line mode , Then press ‘ : ’ ( In English ), At this time, a command line will appear under the terminal , Then choose the operation you want :

  1. ‘ w filename ’ — Document to filename Save the file name of
  2. ‘ wq ’ — Save the file and exit vim
  3. ‘ q ’ — File not saved and exit vim
  4. ‘ q! ’ — Files are not saved and forced to exit vim

Actually ‘ ! ’ The usage of is not rigid ,‘ wq ’ You can also add ‘ ! ’, Used to express as : File saving and forced exit vim, Its main meaning is to express Enforcement It means

4、 Some shortcut keys commonly used in command line mode

The following shortcut keys are Press *, Such as : Add content at the end of a line , You can press... On the keyboard in command line mode A; Delete the content from the specified position to the end of the line , Just stop the cursor in front of the sentence to be deleted , Press on the keyboard in turn d -> $, wait .

【1】 Add at the end of the line

  1. A

【2】 Delete words

  1. Place the cursor in front of the word to be deleted , Press in turn d and W( The following introduction is directly abbreviated as d -> W)
  2. Place the cursor in front of the word to be deleted , At the same time, ignore the space in front of the word :d -> e

【3】 Delete the content from the specified position to the end of the line

  1. d -> $ ( Just stop the cursor in front of the sentence to be deleted )

【4】 Quickly jump to the beginning of the line

  1. 0

【5】 Delete current row

  1. d -> d
  2. To delete continuously 2 Line or more lines , Just add the row number parameter , namely 2 -> d -> d

【6】 Undo change

  1. Undo the previous change :u
  2. Undo the change of the whole line :U
  3. Undo the undo operation of the previous step :Ctrl + R

【7】 Jump

  1. Top jump :Ctrl + g ( An input box appears at the bottom of the terminal ), And then again + g + g
  2. Bottom jump :Ctrl + g, And then again + G
  3. Jump to the specified number of lines : Enter the line number directly n, And then again + G

5、 utilize vim Set the encoding format

5.1 Instructions

  1. :set ff — View the type of current text mode , It's usually doc and unix
  2. :set ff=dos — Change the text type to dos type
  3. :set ff=unix — Change the text type to unix type
  4. :set fileencoding — View the encoding of the current text
  5. :set fenc= code — Converts the encoding of the current text to the specified encoding
  6. :set enc= code — Display the text in the specified encoding , But do not modify the text encoding

5.2 Be careful

  1. Windows The default encoding is GBK,Linux The default encoding is utf-8
  2. commonly Linux File corresponding to the unix The text type of and utf-8 The coding
  3. Each statement needs to be executed in command line mode , Then press ‘ : ’
  4. Probably fileencoding This word is long , In fact, we finished fi Then you can press TAB The completion of , Save time
  5. Text mode type and Text coding is not a thing , Pay attention to the distinction
原网站

版权声明
本文为[Xuanxue closed disciple]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207221940344704.html