当前位置:网站首页>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
边栏推荐
- Jetpack Compose之Navigation组件使用
- [heavyweight] focusing on the terminal business of securities companies, Borui data released a new generation of observable platform for the core business experience of securities companies' terminals
- What is the difference between preamplifier and power amplifier?
- It's too strong. An annotation handles the data desensitization returned by the interface
- [2013] [paper notes] terahertz band nano particle surface enhanced Raman——
- 80 + guests took the stage, users from more than 10 countries attended the meeting, and 70000 + viewers watched the end of "Gwei 2022 Singapore"
- 【2013】【论文笔记】太赫兹波段纳米颗粒表面增强拉曼——
- .NET Core 实现后台任务(定时任务)Longbow.Tasks 组件(三)
- FPGA implementation of IIC bus of IIC protocol (II) (single read / write drive)
- [paper reading] gettext: trajectory flow map enhanced transformer for next POI recommendation
猜你喜欢
![[2022] [paper notes] terahertz quantum well——](/img/05/27e9b6a5b2aebf8aa4604f5992551e.png)
[2022] [paper notes] terahertz quantum well——

一文详解:TMP1750芯片 三通道线性LED驱动器

Three things programmers want to do most | comics
![Log framework [detailed learning]](/img/2f/2aba5d48e8a544eae0df763d458e84.png)
Log framework [detailed learning]

日志框架【详解学习】

FPGA实现IIC协议(二)之IIC总线的FPGA实现(单次读写驱动)

OSI模型第一层:物理层,基石般的存在!

What is the difference between preamplifier and power amplifier?

AE 教程,如何在 After Effects 中对 Illustrator 分图层文档进行动画绘制?

Spark installation and startup
随机推荐
An SQL question about grouping query
Paddlenlp之UIE分类模型【以情感倾向分析新闻分类为例】含智能标注方案)
Moxa serial server model, moxa serial server product configuration instructions
【2020】【论文笔记】基于Rydberg原子的——
PHP file lock lottery to prevent concurrency
GVIM/VIM使用技巧
What is stack and the difference between stacks
Digital security giant entrust revealed that it was attacked by blackmail software gangs in June
基于FPGA的SPI通讯协议实现
Jumpserver administrator account is locked
SQL statement exercise
C#启动程序传递参数丢失双引号,如何解决?
Electronic components - resistance
[paper reading] gettext: trajectory flow map enhanced transformer for next POI recommendation
Clean code and efficient system method
TCL脚本语言详解(1)
ResponseBodyAdvice接口使用导致的报错及解决
[2022] [paper notes] terahertz quantum well——
基于 softether 搭建虚拟私有网络
Redis [2022 latest interview question]