当前位置:网站首页>VIM usage
VIM usage
2022-04-23 10:47:00 【qq1033930618】
VIM
- One 、VIM Open file
- Two 、 Display the line number and highlight the search content
- 3、 ... and 、 exception handling
- Four 、VIM Three models
- 5、 ... and 、 Repeat the order
- 6、 ... and 、 Mobile command
- 7、 ... and 、 Edit command
- 8、 ... and 、 Replace the command
- Nine 、 Indent and repeat
- Ten 、 Find content
- 11、 ... and 、 Find content
- Twelve 、 Insert command
- 13、 ... and 、 Edit command walkthrough
- fourteen 、 Last line command extension
One 、VIM Open file
vi file name Open file
vi file name + Open the file and navigate to the end of the file
vi file name + Row number Open the file and navigate to the specified line
Two 、 Display the line number and highlight the search content
sudo gedit /etc/vim/vimrc
Add a line at the end
set number
set hls
3、 ... and 、 exception handling
vim The terminal generates files during editing
. file name .swp
Reuse vim When you open it, you will be prompted
Four 、VIM Three models
Command mode
Open the file and enter the command mode
location Page turning Copy Paste Delete
Last row mode
In command mode : Get into
:w preservation
:q sign out
:wq Save and exit
:x Save and exit
:q! Exit without saving
Esc Exit to command mode
edit
In command mode i Get into
Esc Exit to command mode
5、 ... and 、 Repeat the order
Repeat command
Numbers command
6、 ... and 、 Mobile command
Move in command mode
On 、 Next 、 Left 、 Right
h towards the left
j Down
k Up
l towards the right
Move in line
w Move a word back
b Move a word forward
0 Head of line
^ Head of line The first position is not a blank character
$ At the end of the line
Rows move
gg Top of file
G end of file
Numbers gg Move to Numbers Number of corresponding lines
Numbers G Move to Numbers Number of corresponding lines
: Digital carriage return Move to Numbers Number of corresponding lines
Screen movement
Ctrl + b | back | Page up |
Ctrl + f | forward | Page down |
H | Head | At the top of the screen |
M | Middle | In the middle of the screen |
L | Low | At the bottom of the screen |
Paragraph move
Look for blank lines
| {
| Last paragraph |
| } | Next paragraph |
| % | Bracket matching and switching |
Mark
| mx | mark | Add tag x,x yes a~z perhaps A~Z Any letter between |
| 'x | | Go straight to the mark x The position of |
* Marked ** If the line is deleted **,** The tag is also deleted **
* If ** Tag with same name added to other lines **,** Previously added tags will also be replaced **
Select the text Can be used with the move command
Esc Return to command mode
| v | Visual Modes | Select the text in normal mode from the cursor position |
| V | Visual line mode | Select the full line the cursor passes through |
| Ctrl + v | Visual block mode | Select text vertically |
7、 ... and 、 Edit command
revoke
| u | undo | Undo the last order |
| CTRL + r | redo | To resume an order of revocation |
Delete
| x | cut | Delete cursor character , Or select the text |
x You can delete the selected content It can also be used with repeated commands
| d( Mobile command ) | delete | Delete the content corresponding to the move command |
| dd | delete | Deletes the line where the cursor is located , Sure ndd Copy many lines |
| D | delete | Delete to end of line |
* dw Delete from cursor position to end of word
* d0 Delete from cursor position to the beginning of a line
* d} Delete from the cursor position to the end of the paragraph
* ndd Delete continuously from the cursor down n That's ok
* d Lines of code G From the line where the cursor is Delete to Specify the line of code All code between
* d'a From the line where the cursor is Delete to Mark a All code between
Copy
| y( Mobile command ) | copy | Copy |
| yy | copy | Duplicate a row , Sure nyy Copy many lines |
| p | paste | Paste |
** Tips **
* command `d`、`x` Similar to the graphic interface ** Cut operation ** —— `CTRL + X`
* command `y` Similar to the graphic interface ** Copy operation ** —— `CTRL + C`
* command `p` Similar to the graphic interface ** Paste operation ** —— `CTRL + V`
* `vi` Medium ** There is also only one text buffer **, If I do it later ** Copy 、 shear ** operation , The contents of the previous buffer will be replaced
** Be careful **
* `vi` Medium ** Text buffer ** And systematic ** clipboard ** Not the same
* So use... In other software `CTRL + C` Copied content , Can't be in `vi` Pass through `P` Command paste
* Can be in ** Edit mode (i)** Next use ** Right click to paste **
8、 ... and 、 Replace the command
| r | replace | Replace the current character | Command mode |
| R | replace | Replace the character after the current line cursor | Replace mode |
Nine 、 Indent and repeat
| >> | Increase indent to the right |
| << | Decrease indent to the left |
| . | Repeat the last order |
Visual mode: select multiple lines at a time to increase or decrease indent
* ** Indent order ** When developing programs ,** Add indents to the code ** More useful !
* Disposable ** Add... Before selecting code 4 A space **, It's called ** Increase Indent **
* Disposable ** Delete... Before selecting code 4 A space **, It's called ** Reduce indent **
* stay ** Visual Modes ** Next , The indent command only needs to use ** One ** `>` perhaps `<`
Ten 、 Find content
| /str enter | lookup str |
* After finding the specified content , Use `Next` Find the next place to appear :
* `n`: Find the next one
* `N`: Find the last one
* If you don't want to see highlights , You can find any content that does not exist in a file
| '*' | Find the word of the current cursor backward |
| '#' | Look forward to the word where the current cursor is |
11、 ... and 、 Find content
Text substitution
:%s/ Old text / New text /g
Check replace
:s/ Old text / New text /g
Confirm replacement
:%s/ Old text / New text /gc
Select each highlight
1. `y` - `yes` Replace
2. `n` - `no` Do not replace
3. `a` - `all` Replace all
4. `q` - `quit` Quit replacing
5. `l` - `last` the last one , And move the cursor to the beginning of the line
6. `^E` Scroll down
7. `^Y` Scroll up
Twelve 、 Insert command
There are several different ways to enter insert Pattern
| i | insert | Insert text before current character | Commonly used |
| I | insert | Insert text at the beginning of the line | More commonly used |
| a | append | Add text... After the current character | |
| A | append | Add text at the end of the line | More commonly used |
| o | | Insert a blank line after the current line | Commonly used |
| O | | Insert a blank line before the current line | Commonly used |
13、 ... and 、 Edit command walkthrough
With numbers
Enter numbers consecutively x Duplicate content
Numbers x + i + Repeat + Esc
1. Input `10`, To repeat 10 Time
2. Input `i` Get into ** Edit mode **
3. Input `*` That is, repeated words
4. Press down `ESC` Back to ** Command mode **, After returning `vi` Will put the second `2、3` Repeat the two steps `10` Time
utilize Visual block Add comments to multiple lines of code
1. Move to the ** The first 1 Line code **, Press `^` Come to the head of the line
2. Press `CTRL + v` Get into ** Visual block ** Pattern
3. Use `j` Select the lines of code you want to add in a row
4. Input `I` Get into ** Edit mode **, And in ** Insert... At the beginning of the line **, Be careful : Be sure to use **I**
5. Input `# ` That is, annotation symbols
6. Press down `ESC` Back to ** Command mode **, After returning `vi` Every line of code that will be selected before ** front ** Insert `# `
^ + CTRL v + Select row + I + '#' Space + Esc
fourteen 、 Last line command extension
| :e . | edit | Will open the built-in file browser , Browse the files in the current directory Enter by car |
:e file name Switch files It can be used Tab completion But the file must have been saved
| :n file name | new | New file |
| :w file name | write | Save as , But still edit the current file , Does not switch files |
Split screen operation
| :sp [ file name ] | split | Increase split screen horizontally |
| :vsp [ file name ] | vertical split | Add split screen vertically |
Control window
> Split windows are based on `CTRL + W` This shortcut is ,`w` The corresponding English word is `window`
| w | window | Switch to the next window |
| r | reverse | Swap windows |
| c | close | Close the current window , But you can't close the last window |
| q | quit | Exit the current window , If it's the last window , Then close vi |
| o | other | Close other windows |
| + | | Increase window height |
| - | | Reduce window height |
| > | | Increase window width |
| < | | Reduce window width |
| = | | Bisect window size |
版权声明
本文为[qq1033930618]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230618497314.html
边栏推荐
- 142. Circular linked list||
- Jerry sometimes finds that the memory has been tampered with, but there is no exception. How should he find it? [chapter]
- 使用zerotier让异地设备组局域网
- Strongest date regular expression
- Can Jerry's AES 256bit [chapter]
- 全栈交叉编译X86完成过程经验分享
- Read integrity monitoring techniques for vision navigation systems - 4 multiple faults in vision system
- A diary of dishes | 238 Product of arrays other than itself
- Shell script interaction free
- Read integrity monitoring techniques for vision navigation systems
猜你喜欢
Download and installation steps of xshell + xftp
Wonderful review | deepnova x iceberg meetup online "building a real-time data Lake based on iceberg"
JUC concurrent programming 07 -- is fair lock really fair (source code analysis)
Introduction to wechat applet, development history, advantages of applet, application account, development tools, initial knowledge of wxml file and wxss file
使用zerotier让异地设备组局域网
SSH uses private key to connect to server without key
/etc/shadow可以破解吗?
UEditor之——图片上传组件大小4M的限制
Example of pop-up task progress bar function based on pyqt5
Reading integrity monitoring techniques for vision navigation systems - 3 background
随机推荐
209. Subarray with the smallest length (array)
Wonderful review | deepnova x iceberg meetup online "building a real-time data Lake based on iceberg"
19、删除链表的倒数第N个节点(链表)
206、反转链表(链表)
SQL Server recursive query of superior and subordinate
Hikvision face to face summary
Kaggle - real battle of house price prediction
Go language practice mode - functional options pattern
中职网络安全2022国赛之CVE-2019-0708漏洞利用
任意文件读取漏洞 利用指南
MySQL common statements
得到知识服务app原型设计比较与实践
Contact between domain name and IP address
解决方案架构师的小锦囊 - 架构图的 5 种类型
Charles function introduction and use tutorial
The courses bought at a high price are open! PHPer data sharing
Six practices of Windows operating system security attack and defense
精彩回顾 | DEEPNOVA x Iceberg Meetup Online《基于Iceberg打造实时数据湖》
Solve the problem of installing VMware after uninstalling
What if Jerry's function to locate the corresponding address is not accurate sometimes? [chapter]