当前位置:网站首页>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. |
边栏推荐
猜你喜欢

About the problem of kicad stuck in win10 version, version 6 x

Kubernetes 理解kubectl/调试

2022年广东高考分数线出炉,一个几家欢喜几家愁

多张动图怎样合成一张gif?仅需三步快速生成gif动画图片

Gif动画怎么在线制作?快试试这款gif在线制作工具

Std:: vector minutes
![[untitled] the CMD command window displays' NPM 'which is not an internal or external command](/img/db/b1ae4b0d1110af1e24887ba3b4fe16.jpg)
[untitled] the CMD command window displays' NPM 'which is not an internal or external command

JS component

Open a restaurant

Use Matplotlib to draw a line chart
随机推荐
买基金在哪里开户安全?求指导
【Try to Hack】vulhub靶场搭建
Let and const commands
Qlogsystem log system configuration use
Luogu p5707 [deep foundation 2. example 12] late for school
Async await to achieve sleep waiting effect
JS determines whether two values are equal, and compares any two values, including array objects
Installing QT plug-in in Visual Studio
Flexible layout (display:flex;) Attribute details
挖财是正规的吗?股票开户安全吗?
Uniapp icon configuration
QT opens the print dialog box in a text editor
Qt: Pro project file
SPARQL learning notes of query, an rrdf query language
QT database connection deletion
JGG | overview of duhuilong group of Hebei University Research on plant pan genomics
Dmsetup command
Why should the coroutine be set to non blocking IO
Ubuntu 20.04 installing mysql8.0 and modifying the MySQL password
How to view the Chrome browser plug-in location