当前位置:网站首页>Gvim/vim tips
Gvim/vim tips
2022-07-23 19:08:00 【qq_ forty-four million nine hundred and eighty-five thousand si】
Blog overview
stay Linux The most commonly used editor in is VIM, however VIM Use and Linux The use of is basically the same , Are based on command line operations , because VIM There are only commands without menus . that , If you want to use VIM You must remember some common commands , It's convenient for us to use VIM To the point of doing what you want . This article will summarize what we often use VIM Mode of operation , For students to learn and convenient for bloggers to review in the future .
VIM Working mode
VIM There are three working modes , Command mode , Insertion mode , Edit mode , Among them, the insertion mode is the same as that we commonly use txt There is little difference in the preparation of documents , But both command mode and edit mode are for us to be faster 、 Better documentation provides .
VIM Common commands
In command mode u Indicates to undo the latest operation .
VIM Several ways of changing from command mode to insert mode
| command | effect |
|---|---|
| a | Insert... After the character of the cursor |
| A | Insert... At the end of the line where the cursor is |
| i | |
| I | Insert... At the beginning of the line where the cursor is |
| o | Insert a new line under the cursor |
| O | Inserts a new line on the cursor |
The above table is in VIM Several ways of changing from command mode to insert mode .
Locate the command
| command | effect |
|---|---|
| :set nu | VIM The editor displays the line number |
| :set nonu | VIM Cancel the display line number |
| gg | To the first line |
| G | To the last row |
| nG | To the first n That's ok |
| :n | To the first n That's ok |
| $ | Move to the end of the line |
| 0 | Move to the beginning of the line |
The delete command
| command | effect |
|---|---|
| x | Delete cursor character |
| nx | After deleting where the cursor is n Characters |
| dd | Deletes the line where the cursor is located |
| ndd | Delete the cursor and the n That's ok |
| dgg | Delete all lines before the line where the cursor is located |
| dG | Delete all lines after the line where the cursor is located |
| D | Delete the cursor line to the end of the line |
| :n1,n2d | Deletes the row of the specified range |
Copy and cut commands
| command | effect |
|---|---|
| yy | Copy the current row |
| nyy | Copy below the current line n That's ok |
| dd | Cut the current line |
| ndd | Cut below the current line n That's ok |
| p,P | Paste under or on the line where the current cursor is located |
Replace and cancel commands
| command | effect |
|---|---|
| r | Replaces the character where the cursor is |
| R | Replace the character from where the cursor is , Press Esc end |
| u | Cancel the previous operation |
Find and replace commands
| command | effect |
|---|---|
| /string | Search for the specified string |
| set ic | Ignore case when searching |
| n | Specify the next occurrence position of the string when searching |
| :%s/old/new/g | Full text replacement string ,gc It means that each string needs to be manually judged by yourself, which is the most commonly used |
| :n1,n2s/old/new/g | Replace strings within a certain range |
Save command
| command | effect |
|---|---|
| :w | Save changes |
| :w new_filename | Save as the specified file |
| :wq | Save the changes and exit |
| ZZ | Shortcut key , Save the changes and exit |
| :q! | Exit without modification |
| :wq! | Save the changes and exit |
VIM Using skills
Import all the contents of another file into the current file
command : Enter... In edit mode :r+ The file name of the import file
Example ::r test.txt
Don't quit VIM Under the premise of , perform Linux command , And print the executed results to the current file
command : Enter... In edit mode :r ! command
Example ::r !ls
stay VIM Define shortcuts in the editor
command :map Shortcut key Trigger a command
Example :map ^p I# <ESC>
The whole replacement of words
command : ab
Example :ab always always @(posedge sclk or negedge)
How to save the current VIM Set the shortcut keys and replace them as a whole
Create a folder under the current user .vimrc The file of , Write the created shortcut key to the file
Example :vim root/.vimrc
边栏推荐
- Storage structure and method of graph (II)
- [paper reading] gettext: trajectory flow map enhanced transformer for next POI recommendation
- FPGA实现IIC协议(二)之IIC总线的FPGA实现(单次读写驱动)
- Access intranet rds+mysql through SSH
- LeetCode 0131. 分割回文串
- Design of UART interface based on FPGA
- [2020] [paper notes] phase change materials and Hypersurfaces——
- @JPA annotation in entity
- How to realize the digital transformation of the banking industry
- 【2013】【论文笔记】太赫兹波段纳米颗粒表面增强拉曼——
猜你喜欢

【2020】【论文笔记】相变材料与超表面——

Learn and understand Architecture Design from business development
![Gradle [graphic installation and use demonstration]](/img/e4/ac69e490fd06ed4ad6a90972273373.png)
Gradle [graphic installation and use demonstration]

1259. Programmation dynamique de poignée de main disjointe

How does the NiO mechanism of jetty server cause out of heap memory overflow

Learn about spark project on nebulagraph

Access intranet rds+mysql through SSH

Design of UART interface based on FPGA

Great God "magic change" airpods, equipped with usb-c interface, 3D printing shell makes maintenance easier

How can win11 add 3D effects to pictures? Win11 method of adding picture 3D effect
随机推荐
Multithreading and high concurrency Day11
80 + guests took the stage, users from more than 10 countries attended the meeting, and 70000 + viewers watched the end of "Gwei 2022 Singapore"
Deepstream learning notes (II): description of GStreamer and deepstream-test1
【2018】【论文笔记】石墨烯场效应管及【1】——GFETs的种类和原理,GFETs特性,GFETs在太赫兹中的应用和原理
SQL statement exercise
Handwriting bind, call, apply is actually very simple
【论文阅读】GETNext: Trajectory Flow Map Enhanced Transformer for Next POI Recommendation
迷宫类dp整合
【2020】【论文笔记】基于二维光子晶体的光控分光比可调Y——
11. Basic concepts of neural network
【ONNX】动态输入尺寸的问题(多输出/多输入)
How to replace the double quotation marks of Times New Roman in word with the double quotation marks in Tahoma
Leetcode 0131. split palindrome string
1259. 不相交的握手 動態規劃
Leetcode sword finger offer II 115. reconstruction sequence: diagram topology sorting
Implementation of IIC protocol with FPGA (I) IIC bus protocol
一、爬虫概念及基本流程
Source code analysis of ThreadPoolExecutor
Error "failed to fetch" XXX "temporary failure resolvingw: some index files failed to download" solution
Tcl脚本语言基础(2)