当前位置:网站首页>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. |
边栏推荐
- Function of getinstance() method
- Clinical Chemistry | 张建中/徐健开发幽门螺杆菌单细胞精准诊疗技术
- basic_ String mind map
- Output 0 ~ n digits and output multiple times
- Master XSS completely from 0 to 1
- Gif动画怎么在线制作?快试试这款gif在线制作工具
- 多张动图怎样合成一张gif?仅需三步快速生成gif动画图片
- JS floating point multiplication and division method can not accurately calculate the problem
- Iterator failure condition
- One question per day, punch in
猜你喜欢

Flexible layout (display:flex;) Attribute details

Add the resources directory under test in idea

Ubuntu 20.04 installing mysql8.0 and modifying the MySQL password

SPARQL learning notes of query, an rrdf query language

How to crop GIF dynamic graph? Take this picture online clipping tool

15 -- k points closest to the origin

Thymeleaf Usage Summary

QT loading third-party library basic operation

Application of TSDB in civil aircraft industry

Arithmetic operations and expressions
随机推荐
【Try to Hack】vulhub靶场搭建
About the problem of kicad stuck in win10 version, version 6 x
2020-03-20
多张动图怎样合成一张gif?仅需三步快速生成gif动画图片
Application of TSDB in civil aircraft industry
15 -- 最接近原点的 K 个点
Thymeleaf Usage Summary
Power automatic test system nsat-8000, accurate, high-speed and reliable power test equipment
[Ocean University of China] information sharing for the first and second examinations of postgraduate entrance examination
Review of arrays and pointers triggered by a topic
Build a minimalist gb28181 gatekeeper and gateway server, establish AI reasoning and 3D service scenarios, and then open source code (I)
网上股票开户安不安全?有谁知道呢
Open a restaurant
Vs2019 scanf error
Clinical Chemistry | 张建中/徐健开发幽门螺杆菌单细胞精准诊疗技术
Get the parameters in the URL and the interchange between parameters and objects
JS Base64 Library Learning
Go语言Zap库Logger的定制化和封装使用详解
HMS core machine learning service realizes simultaneous interpretation, supports Chinese-English translation and multiple voice broadcast
[try to hack] vulhub shooting range construction