当前位置:网站首页>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. |
边栏推荐
- Qlogsystem log system configuration use
- Disable scrolling in the iPhone web app- Disable scrolling in an iPhone web application?
- How to make GIF animation online? Try this GIF online production tool
- 90 后眼中的理想 L9:最简单的产品哲学,造最猛的爆款 | 指南斟
- QQ情话糖果情话内容获取并保存
- Output 0 ~ n digits and output multiple times
- ‘make_ unique’ is not a member of ‘std’
- Remove interval (greedy)
- One question per day, a classic simulation question
- Basic usage of markdown (plain text and grammar)
猜你喜欢

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

Use Matplotlib to draw a line chart

QQ love talk candy love talk content acquisition and storage

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

Yolov3 spp Darknet version to caffemodel and then to OM model

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

Time stamp calculation and audio-visual synchronization of TS stream combined video by ffmpeg protocol concat
![[Ocean University of China] Data Sharing for retest of initial Examination](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[Ocean University of China] Data Sharing for retest of initial Examination

Master XSS completely from 0 to 1

From 408 to independent proposition, 211 to postgraduate entrance examination of Guizhou University
随机推荐
Flexible layout (display:flex;) Attribute details
C language escape character and its meaning
【Try to Hack】vulnhub DC1
Dmsetup command
QT file reading -qfile
Compile Caffe's project using cmake
How to crop GIF dynamic graph? Take this picture online clipping tool
How to combine multiple motion graphs into a GIF? Generate GIF animation pictures in three steps
QT database connection deletion
Qt: Pro project file
14 -- validate palindrome string II
分饼干问题
Function of getinstance() method
Master XSS completely from 0 to 1
Common formatting methods for amount numbers
Installing QT plug-in in Visual Studio
全国首例,中国电信 5G 井下人员定位项目正式商用:可实时跟踪位置,保障作业安全
[Ocean University of China] information sharing for the first and second examinations of postgraduate entrance examination
Async await to achieve sleep waiting effect
Get the parameters in the URL and the interchange between parameters and objects