当前位置:网站首页>Summary of common commands of vim
Summary of common commands of vim
2022-07-23 11:08:00 【Jiuli ⠂】
vim Summary of common commands
List of articles
Click on Esc Key , And then click :
Enter command edit mode
1、 lookup
| command | explain |
|---|---|
| /str | Find down str Characters or words |
| ?str | Upward search str Characters or words |
| n | In search mode , Next character |
| N | In search mode , Previous character |
| v{str} -> * | Choose str, Press “*” Will find once str Position of appearance |
| /{str}\> | Find the whole word accurately str, Instead of finding string,"\>" Match end ,“\<” Match start |
2、 Replace
| command | explain |
|---|---|
| s/{pattern}/{replace}/ | Replace the first occurrence of matching regular text pattern by replace |
| s/{pattern}/{replace}/g | Replace all matching regular text in the current line pattern by replace |
| %s/{pattern}/{replace}/g | Replace all matching regular text globally pattern by replace |
| s/{pattern}/{replace}/gc | Replace all matching regular text globally as replace, Need to confirm (confirm) |
| 2,5/{pattern}/{replace}/g | Replace 2 To 5 The line matching regular text is replace |
3、 edit
3.1 Character insertion 、 Delete
| command | explain |
|---|---|
| x | Delete character backward |
| X | Delete characters forward |
| s | Replace character |
| i | Insert... In front of the cursor |
| I | Insert at the beginning of line |
| a | Insert... After the cursor |
| A | Insert... At the end of the line |
| c | change (change), Delete and enter edit mode |
| C | change (change), Delete the character at the end of the line after the cursor and enter the editing mode |
3.2 word
| command | explain |
|---|---|
| diw | Delete the word where the cursor is , No spaces ,del inner word |
| daw | Delete the word where the cursor is , Include spaces ,del a word |
| dw | Delete the character after the cursor to the beginning of the next word , Include spaces ,d4w— Delete 4 Word ,d4e,d$ |
3.3 Line operation ----- Delete 、 Insert 、 edit
| command | explain |
|---|---|
| D | Delete the character after the cursor to the end of the line , It can't be edited |
| C | Modify the character after the cursor to the end of the line , Editable |
| S | Modify entire line , Editable |
| dd | Delete entire line |
| yy | Copy entire line |
| o | Insert a line down |
| O | Insert a line up |
| A | Insert before the beginning of the line |
| I | Insert... At the end of the current line |
| J | Two lines in one ,{n}J:n Line by line |
3.4 revoke
| command | explain |
|---|---|
| u | To withdraw forward |
| ctrl+r | Recover backward |
3.5 edit ( Copy , shear , Delete )
| command | explain |
|---|---|
| p | Copy a line down |
| P | Copy a row in the current row |
| d | shear |
| n,md | Delete n To m Row content |
| n,d | Delete n In the future |
| .,$d | Delete all lines after the line where the cursor is located |
3.6 state
| command | explain |
|---|---|
| ctrl+g | Count the information of the current line |
| g->ctrl + g | Count all content information |
3.7 choice
| command | explain |
|---|---|
| v | Start at cursor position , The cursor passes through the position to select |
| V | Start on the line where the cursor is located , Select the line where the cursor passes |
| ctrl+v | Start at cursor position , Form the selected matrix |
| ggVG | Check all the text , among gg To jump to the beginning of the line ,V Select the whole line ,G At the end of |
3.8 file
| command | explain |
|---|---|
| edit foo.txt | Edit another foo.txt file , Abbreviation :e foo.txt |
| vim 1.txt 2.txt 3.txt | Edit multiple files at the same time |
| vim -R file.txt | Read only open |
| next (previous) | Cut to the next |
| n (prev) | Cut to the previous |
| wn (wprev) | Next after saving |
| args | Displays the file being edited and the list of files |
| split | Open a new window for the file |
| split 2.txt | by 2.txt File opens a new window |
| vsplit | Split the window vertically |
| vim -o 1.txt 2.txt | Open a window for each file |
| vimdiff 1.txt 2.txt | Compare the differences between files |
| tabe 1.txt | ask 1.txt Create tabs ,gt Switch |
| q|w|wq all | give up | preservation | Save all and exit |
| only | Close other windows except the current window |
| sav|saves newfileName.txt | Save as new ( Saved ) |
| f|file newFileName.txt | Save as new ( Not saved ) |
| ctrl + w | Switch windows |
4、 Move
4.1 word
| command | explain |
|---|---|
| w | The first character of the next word |
| W | The first character of the next long word |
| e | The last character of the next word |
| E | The last character of the next long word |
| b | The first character of the previous word |
| B | The first character of the previous long word |
| g[e|E] | Previous ( Long ) The last character of the word |
4.2 That's ok
| command | explain |
|---|---|
| ( Numbers 0|btn[home]) | Head of line : Include spaces |
| ^ | Head of line : Non empty character |
| {n}$|btn[end] | n End of line : Non empty character |
| gg | first line |
| G | The last line |
| {n}G | To the first n Line beginning |
4.3 sentence
| command | explain |
|---|---|
| ( | To the beginning of the sentence |
| ) | To the end of the sentence |
4.4 The paragraph
| command | explain |
|---|---|
| { | To the beginning of the paragraph |
| } | To the end of the paragraph |
4.5 The screen
| command | explain |
|---|---|
| ctrl + y | Scroll up |
| ctrl + e | Scroll down |
| ctrl + u | Roll up half a screen |
| ctrl + d | Scroll down half screen |
| ctrl + b | Roll up half a screen |
| ctrl + f | Scroll down half screen |
4.6 Jump
| command | explain |
|---|---|
| [f|F]{x} | Jump to the 【 Next 】|【 On 】 One x Character position , A semicolon (;) Look down , comma (,) reverse |
| ctrl + ] | Jump to the previous application |
| ctrl + o | Jump to the previous cursor position ctrl + I Transfer back |
| % | Match the other corresponding bracket of the closing bracket |
| {n}% | Jump to file n% The place of |
| [H|M|L] | Jump to file 【 first line 】|【 Middle row 】|【 End line 】 The beginning of the line |
4.7 Mark
| command | explain |
|---|---|
| m[a-z] | ( The same file is in lowercase ) Make a for the current position of the cursor [a-z] The tag (mark a), Recall a Mark , Use a. Clear all marks :delm! |
| m[A-Z] | ( Different documents are capitalized ) Make a for the current position of the cursor [A-Z] The tag (mark A), Transfer to A Mark , Use A. Clear all marks :delm! |
| marks A | see A Mark the corresponding content |
| ‘’ | Two before and after mark Jump between |
4.8 other
| command | explain |
|---|---|
| h|j|k|i | Left , Next , On , Right |
| {n}[h|j|k|i] | towards 【 Left | Next | On | Right 】 Move n |
5、 Line break
| command | explain |
|---|---|
| zfap | Fold a paragraph of text |
| zf | Create a line break |
| zo | Open wrap |
| zc | Close the fold |
6、 preservation 、 sign out
| command | explain |
|---|---|
| w | preservation |
| q | sign out |
| ZZ|WQ|x | Save and exit |
| ZQ|q! | Exit without saving |
| w{filename} | Save as file |
7、 register
| command | explain |
|---|---|
| reg | Check register |
| ""p | Paste using anonymous registers |
| "ayy | Copy the current line to the register a in |
| "ap | Paste a The contents of the register |
| "+p | Paste the contents of the clipboard |
| ":p | Paste the previous vim command , With colon -: The order of |
| "/p | Paste the last one in vim Keywords searched in |
| "_[d|y] | Black hole replication , Black hole shear |
8、 Set up
| command | explain |
|---|---|
| set h|search | Turn on highlight search set noh|search close |
| set autoindent | Turn on auto indent |
| syntax | enable |
| set nu! | According to the line Numbers |
| set warp | Word wrap |
边栏推荐
- Concepts et différences de bits, bits, octets et mots
- pyqt5使用QPainter绘制坐标轴并显示散点图
- 简述redis特点及其应用场景
- Cadence (IX) 17.4 rules and spacing settings
- Activiti工作流使用之Activiti-app的安装及流程创建
- Redis source code and design analysis -- 13. Ordered collection objects
- js中拼接字符串,注意传参,若为字符串,则需要加转义字符
- 十年架构五年生活-01毕业之初
- Deploy storageclass trample record
- 单点登录-认证服务器与客户端的session过期时间如何统一
猜你喜欢

Meyer burger Siemens industrial computer maintenance and machine tool maintenance

Redis源码与设计剖析 -- 6.压缩列表

Master slave synchronization step read / write separation + self encountered error sharing

Pytorch (V) -- pytorch advanced training skills

部署metersphere

主从同步步骤读写分离+自遇错误分享

"The six programming languages I want most!"

一次 MySQL 误操作导致的事故,「高可用」都不好使了

Cadence(九)17.4规则与间距设置

讲师征集令 | Apache DolphinScheduler Meetup分享嘉宾,期待你的议题和声音!
随机推荐
Web server failed to start. Port 8080 was already in use.
[visual slam] orb slam: tracking and mapping recognizable features
PyTorch(五)——PyTorch进阶训练技巧
[information system project manager] Chapter VI recheck schedule management knowledge structure
Deploy metersphere
Notes and Thoughts on the red dust of the sky (IV) invalid mutual value
又更新了, IDEA 2022.2 正式发布
Meyer Burger梅耶博格西门子工控机维修及机床养护
Cadence学习之路(八)PCB放置元器件
QT style syntax definition access, can check the data, can be automatically generated
N wars of C language -- common body and enumeration (VIII)
Déploiement du projet (version abrégée)
开发必备之Idea使用
Activiti工作流使用之流程结构介绍
H1 -- HDMI interface test application 2022-07-15
字典创建与复制
Deploy storageclass trample record
支付宝DTS架构
sort
PMP practice once a day | don't get lost in the exam -7.22