当前位置:网站首页>Common operations in VIM
Common operations in VIM
2022-06-25 14:56:00 【Long water and sky】
Catalog
One 、 Three working modes
1. Command mode
In this mode , Use the arrow keys and k、j、h、i Move cursor position , In addition, the contents of the file can be copied 、 Paste 、 Replace and delete .
2. The input mode
In this mode ,Vim You can write to a file , Enter... In command mode i、I、a、A、o、O Wait to insert the command , After editing, click Esc Key to return to command mode .
3. Edit mode
This mode is used to save the specified contents in the file 、 Find or replace . Type... In command mode “:” key , here Vim At the bottom left of the window “:” Symbol , You can input relevant instructions for operation .
After executing the command Vim Will automatically return to command mode , To return directly to the command mode , Knock Esc that will do .
Two 、 Shortcut direction keys
| Shortcut key | Function description |
|---|---|
| h | Move the cursor one bit to the left |
| l | The cursor moves one digit to the right |
| j | Move the cursor down one line |
| k | Move the cursor up one line |
| w or W | Move the cursor to the beginning of the next word |
| b or B | Move the cursor to the beginning of the previous word |
| e or E | Move the cursor to the end of the next word |
| nw or nW | n Is the number , Indicates that the cursor moves to the right n Word |
| nb or nB | n Is the number , Indicates that the cursor moves to the left n Word |
3、 ... and 、 Find the text
| Shortcut key | Function description |
|---|---|
| /abc | Find the string forward from the cursor position abc |
| ?abc | Find the string backwards from the cursor position 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 |
| n | Repeat the last lookup instruction in the same direction |
| N | Repeat the last lookup instruction in the opposite direction |
Four 、 replace text
| 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 , Knock “ Esc” It's over |
| :s/a1/a2/g | All of the a1 Use both a2 Replace |
| :n1,n2s/a1/a2/g | Put... In the file n1 To n2 Everything in the line a1 Use both a2 Replace |
| :g/a1/a1/g | Put all the a1 Use both a2 Replace |
5、 ... and 、 Delete text
| Shortcut key | Function description |
|---|---|
| x | Deletes the character where the cursor is located |
| dd | Deletes the line where the cursor is located |
| ndd | Delete current row ( Including this trip ) after n Line text |
| dG | Delete everything from the cursor line to the end of the file |
| D | Delete the cursor position to the end of the line |
| :a1,a2d | Remove from a1 Row to a2 The text content of the line |
6、 ... and 、 Copy and paste text
| Shortcut key | Function description |
|---|---|
| p | Paste the contents of the clipboard behind the cursor |
| P( Capitalization ) | Paste the contents of the clipboard in front of the cursor |
| y | Copy the selected text to the clipboard |
| yy | Copy the cursor line to the clipboard , This command can be preceded by the number of words n, Multiple lines can be copied |
| yw | Copy the word at the cursor position to the clipboard |
7、 ... and 、 Save exit text
| Shortcut key | Function description |
|---|---|
| :wq | Save and exit |
| :wq! | Save and force exit |
| :q | Do not save , sign out |
| :q ! | Do not save , And forced out |
| :w | preservation , But don't quit |
| :w! | Force save text |
| :w filename | Save as filename file |
| zz | immediate withdrawal |
8、 ... and 、 Cursor movement
| Shortcut key | Function description |
|---|---|
| 0 or ^ | Move the cursor to the beginning of the current line |
| $ | Move the cursor to the end of the current line |
| n$ | When the cursor moves to the current line, only n The end of the line ,n Is the number |
| gg | The cursor moves to the beginning of the file |
| G | Move the cursor to the end of the file |
| nG | Cursor moves to the n That's ok ,n Is the number |
| :n | Quickly define the cursor to the beginning of the specified line ( Use... In edit mode ) |
Nine 、 Undo and redo operations
| Shortcut key | Function description |
|---|---|
| u | cancel your last action |
| ctrl + r | Resume the last operation |
Ten 、 Bracket lookup operation
| Shortcut key | Function description |
|---|---|
| % | find () [] {} The other half of the brackets , And find begin…end,task…endtask etc. |
边栏推荐
- 分饼干问题
- [deep learning] multi task learning of multiple datasets data sets missing labels
- Qt: Pro project file
- JS floating point multiplication and division method can not accurately calculate the problem
- Differences between member variables and local variables
- SPARQL learning notes of query, an rrdf query language
- 买基金在哪里开户安全?求指导
- [HBZ sharing] use of locksupport
- Function of getinstance() method
- Jaspersoft studio installation
猜你喜欢

JS get the height and width corresponding to the box model (window.getcomputedstyle, dom.getboundingclientrect)

Power automatic test system nsat-8000, accurate, high-speed and reliable power test equipment

How to view the Chrome browser plug-in location

New good friend Pinia, leading the new era of state management

Ubuntu 20.04 installing mysql8.0 and modifying the MySQL password

QQ情话糖果情话内容获取并保存

From 408 to independent proposition, 211 to postgraduate entrance examination of Guizhou University

Jaspersoft studio installation

Flexible layout (display:flex;) Attribute details

JS recursion and while
随机推荐
[deep learning] multi label learning
网上股票开户安不安全?有谁知道呢
14 -- validate palindrome string II
What moment makes you think there is a bug in the world?
Dmsetup command
About the problem of kicad stuck in win10 version, version 6 x
Gif动画怎么在线制作?快试试这款gif在线制作工具
C language LNK2019 unresolved external symbols_ Main error
Design and implementation of thread pool
现在股票开户用什么app最安全?知道的给说一下吧
Uniapp cloud packaging app
NBD Network Block Device
Common formatting methods for amount numbers
买基金在哪里开户安全?求指导
What is the difference between escape, encodeuri and encodeuricomponent?
【Try to Hack】vulnhub DC1
How to cut the size of a moving picture? Try this online photo cropping tool
JS to verify whether the string is a regular expression
QQ情话糖果情话内容获取并保存
One question per day, a classic simulation question