当前位置:网站首页>VIM command Encyclopedia
VIM command Encyclopedia
2022-06-12 03:24:00 【Wangyue Lake】
vim The command of
1.vim Introduce
vim The editor has three modes :
Command mode 、 Edit mode 、 Last row mode
Mode to mode switching method :
(1) In command mode , Input “:” after , Enter last line mode
(2) In last line mode , Press esc Slow down 、 Press two times. esc Fast back 、 Or delete all commands , You can go back to command mode
(3) In command mode , Press down i、a Isobond , Can be included in edit mode
(4) In edit mode , Press down esc, You can go back to command mode
vim Open file :
| Vi The options used | say bright |
|---|---|
| vim filename | Open or create a new file , And place the cursor at the beginning of the first line |
| vim -r filename | Back to the last vim Files that crash when opened |
| vim -R filename | Put the specified file in read-only mode Vim Editor |
| vim + filename | Open file , And place the cursor at the beginning of the last line |
| vi +n filename | Open file , And place the cursor on the n The first part of the line |
| vi +/pattern filename | Open the document , And place the cursor on the first and pattern The matching position |
| vi -c command filename | Before editing a file , Execute the specified command first |
2. Command mode
1. Cursor movement
| Shortcut key | Function description |
|---|---|
| jkhl | Basically up, down, left and right |
| gg | Move the cursor to the first line of the document |
| G | The cursor moves to the end of the document |
| ^ or _ | The cursor moves to the first non empty character at the beginning of the line |
| home Key or 0 perhaps g0 | The cursor moves to the first character at the beginning of the line |
| g_ | The cursor moves to the last non empty character at the end of the line |
| end or or person g perhaps g or person g | The cursor moves to the last character at the end of the line |
| gm | The cursor moves to the middle of the current line |
| w/W | Move the cursor forward one word ( Uppercase ignore /- And so on ) |
| b/B | Move the cursor back one word ( Uppercase ignore /- And so on ) |
| e/E | Move to the end of the word ( Uppercase ignore /- And so on ) |
| ctrl+b or pageUp key | Flip screen operation , Turn up |
| ctrl+f or pageDn key | Flip screen operation , Turn down |
| Numbers +G | Quickly move the cursor to the specified line |
| `. | Move to the last edit |
| Numbers + Up and down direction key | Subject to the current cursor , Up / Move down n That's ok |
| Numbers + Left right key | Subject to the current cursor , towards the left / Move right n Characters |
| H | Move to the top of the screen |
| M | Move to the middle of the screen |
| L | Move to the end of the screen |
| z+Enter key | The current line is at the top of the screen |
| z+ . | The current line is in the middle of the screen |
| z+ - | The current line is at the bottom of the screen |
| shift+6 | Move the cursor to the beginning of the line |
| shift+4 | Move the cursor to the end of the line |
| - | Move to the first non empty character on the previous line |
| + | Move to the first non empty character on the next line |
| ) | Move one sentence forward |
| ( | Move one sentence back |
| } | Move a paragraph forward |
| { | Move a paragraph forward |
| count l | Move to count Column |
| counth | Move to the left count character |
| countl | To the right count character |
| countgo | Move to count character |
2. Select content
| Shortcut key | Function description |
|---|---|
| v | Make character selection |
| V | Make line selection |
| gv | Select the last selection |
| o | The cursor moves to another end of the selection |
| O | The cursor moves to another corner of the selection |
| ctr + V | Make block selection |
3. Copy ( With the paste command p Use )
| Shortcut key | Function description |
|---|---|
| y | Copy the selected text to the clipboard |
| n+yy | Copy the line where the cursor is , This command can be preceded by a number n, Multiple lines can be copied |
| yw | Copy the word at the cursor position |
| ctrl+v + Direction key +yy | ctrl+v, And press the direction key to select the block , Press down yy Copy |
4. shear
| Shortcut key | Function description |
|---|---|
| dd | shear Cursor in line |
| Numbers +dd | Subject to the behavior of the cursor ( Contains the current line ), Cut down the specified number of rows |
| D | Cut cursor line |
5. Paste
| Shortcut key | Function description |
|---|---|
| p | The contents of the clipboard Paste after cursor |
| P( Capitalization ) | The contents of the clipboard Paste in front of the cursor |
6. Delete
| Shortcut key | Function description |
|---|---|
| x | Delete Cursor position The characters of |
| X( Capitalization ) | Delete In front of the cursor A character |
| dd | Delete Cursor in line , After deleting , Move the next line up |
| D | Delete Cursor position to end of line The content of , After deleting , The next line does not move up |
| ndd | Delete current row ( Including this trip ) after n Line text |
| dw | Move the cursor to the beginning of the word to delete the word |
| dG | Delete everything from the cursor line to the end of the file |
| :a1,a2d | Remove from a1 Row to a2 The text content of the line |
7. revoke / recovery
| Shortcut key | Function description |
|---|---|
| u | revoke |
| ctrl+r | recovery |
| U( Capitalization ) | Undo all edits |
8. Character conversion
| Shortcut key | Function description |
|---|---|
| ~ | Convert case |
| u | Become lowercase |
| U | Become capital |
9. Shortcut keys for editing commands
| Shortcut key | Function description |
|---|---|
| ↑ or ctr + p | Last order |
| ↓ or ctr + n | Next order |
| ctr + b | Move to the beginning of the command line |
| ctr + e | Move to the end of the command line |
| ctr + ← | One word to the left |
| ctr + → | One word to the right |
3. Last row mode (: xxx command )
1. preservation / Exit file operation
| command | Function description |
|---|---|
| :wq | Save and exit Vim Editor |
| :wq! | Save and force exit Vim Editor |
| :q | Quit without saving Vim Editor |
| :q! | Do not save , And forced out Vim Editor |
| :w | Save but don't quit Vim Editor |
| :w! | Force save text |
| :w filename | Save as filename file |
| x! | Save text , And exit Vim Editor |
| ZZ | immediate withdrawal Vim Editor |
2. lookup :“/ key word ”
In the search results , use N、n You can switch between up and down results ; Input “nohl”, You can unhighlight
| Shortcut key | Function description |
|---|---|
| /abc | From the cursor position Look ahead character string abc |
| /^abc | Looking to abc For the line at the beginning of the line |
| /abc$ | Looking to abc Is the line at the end of the line |
| ?abc | From the cursor position Look behind character string abc |
| n or ; | Repeat the last lookup instruction in the same direction |
| N or , | Repeat the last lookup assignment in the opposite direction |
3. Replace
| Shortcut key | Function description |
|---|---|
| r | Replace the character where the cursor is located |
| R | Replace characters from where the cursor is , Its input content will cover the text of the same length behind , Press “Esc” Can end |
:s/a1/a2 | Replace The first place on the current cursor line Eligible content |
:s/a1/a2/g | Replace The current cursor line be-all a1 Use both a2 Replace |
| :%s /a1 /a2 | Replace All right in , First of all Eligible content |
| :%s /a1 /a2/g | Replace All right in , all Eligible content |
| :n1,n2 s/a1/a2 | Put... In the file n1 To n2 That's ok in First of all a1 Use both a2 Replace |
| :n1,n2 s/a1/a2/g | Put... In the file n1 To n2 That's ok in all a1 Use both a2 Replace |
4. Line number display :“: set nu”;
- Line number display
: set nu - Cancel line number display :“: set nonu”
5. File switching
Use vim After opening multiple files , You can switch in the last line mode .
- View all currently open files :“:files”(%a Indicates the active state ,# Represents the last open file )
- Switch to the specified file :“:open file name ”
- Switch to the previous article (back previous):“:bp”
- Switch to next file (back next):“:bn”
4. Edit mode
| Shortcut key | Function description |
|---|---|
| i | At present Insert... At cursor position , The text behind the cursor moves to the right |
| I | stay Insert at the beginning of the line where the cursor is located , The beginning of a line is the first non white space character of the line , It is equivalent to moving the cursor to the beginning of the line to execute i command |
| o | stay Insert... Below the line where the cursor is located A new line . The cursor stops at the beginning of an empty line , Waiting for input text |
| O( Capitalization ) | stay Insert... On the line where the cursor is located A new line . The cursor stops at the beginning of an empty line , Waiting for input text |
| a | At present Insert... After the cursor position |
| A | stay Insert at the end of the line where the cursor is , It is equivalent to moving the cursor to the end of the line and then executing a command |
| esc key | Exit edit mode |
5. Expand
1. Code color display :“:syntax on/off”
2.vim Built in calculator :
a. Enter edit mode
b. Press down “ctrl+r”, The cursor becomes a quotation mark ,, Input “=”, The cursor goes to the last line
c. Enter what you want to calculate , Press down enter after , The calculation result replaces the quotation marks in the previous step , Cursor recovery
3.vim Configuration of
a. On file open , The configuration entered in the last line mode is temporary , The configuration is invalid after closing the file
b. Modify personal profile , You can permanently save your personal configuration (~/.vimrc, If not, you can create your own )
c. Modify global profile , Effective for each user (vim Bring their own ,/etc/vimrc)
notes : Personal profiles have higher priority , When personal configuration conflicts with global configuration , The system is subject to the personal profile of the current user
4. Abnormal exit
After editing the file , Exit without normal saving , An exception will be generated to exit the swap file (. original file name .swp)
Delete the swap file , When you open the file again , No prompting :“#rm -f . original file name .swp”
5. Alias mechanism : Custom instruction
Linux in , There is an alias mapping file : ~/.bashrc
Modify file content , You can customize the instructions , It will take effect after you log in to your account again
6. File shortcuts
For deep files , You can create file shortcuts , Easy to follow up :#ln -s The source path New path
7.** Exit mode **
(1) stay vim Exit file editing mode in , have access to “:q” perhaps “:wq”
(2) It is recommended to use “:x”: The use effect is equivalent to wq, If the file is changed, save it first and then exit ; But if the file has not been modified , You just quit , The file update time will not be modified , Avoid the user's determination of the file modification time
边栏推荐
- 2020-12-06
- xml
- Redis gets the set of keys prefixed with XXX
- Application of acrelcloud-6000 secure power cloud platform in a commercial plaza
- Introduce the functions of the new project aleo
- Yu Xia looks at win system kernel -- debugging
- Min25 sieve
- Detailed explanation of data platform SQL development and function use
- ARD3M电动机保护器在煤炭行业中的应用
- Requirements and business model analysis requirements 13 data modeling
猜你喜欢

2020-12-06

mysql/oracle 以唯一时间为分界,小于等于该时间求和,大于该时间求和

errno: -4078, code: ‘ECONNREFUSED‘, syscall: ‘connect‘, address: ‘127.0.0.1‘, port: 3306; Postman error

Demand and business model innovation - demand 10- observation and document review

Machine learning - dimensionality reduction (data compression, data visualization)

In 2022, don't you know the difference between arrow function and ordinary function?
![[Business Research Report] 2021 global mobile game player white paper - download link attached](/img/6f/4425ead27fc3cf117f6756502477cf.jpg)
[Business Research Report] 2021 global mobile game player white paper - download link attached
![[Business Research Report] the salary growth rate report of each industry in 2022 includes regional growth rate - download link is attached](/img/11/291f858ce2444f2fa96c89f7454c17.jpg)
[Business Research Report] the salary growth rate report of each industry in 2022 includes regional growth rate - download link is attached

微信小程序项目实例——双人五子棋

微服务概念及介绍
随机推荐
ics-07
How do I make the mouse wheel work in the VB6 ide- How can I make mousewheel work in VB6 IDE?
Leetcode 6[finding rules] Z-transform the leetcode path of heroding
C language array
How to prevent electrical fire in shopping malls?
cupp字典生成工具(同类工具还有crunch)
如何防止商場電氣火灾的發生?
In 2022, don't you know the difference between arrow function and ordinary function?
In 2022, why is there a market for Shanzhai products?
Simple database connection example
Inverted string - two solutions
Computer configuration suggestions for learning modeling
Lighting Basics: optical model
An example of how to migrate the stock equipment of the Internet of things platform to the enterprise version with one click
Special information | liquor (Baijiu, beer, wine)
Go syntax variable
Calculus review 2
[Business Research Report] analysis report on online attention of China's e-sports industry in 2021 - download link attached
The idea of setting the flash memory management and resource size, and the quantitative relationship among parallelism, slot, and taskmanager quantity
Introduce the functions of the new project aleo