当前位置:网站首页>vim编辑器知识总结
vim编辑器知识总结
2022-07-04 22:30:00 【宋小羽】
1. 三种模式
输入vi/vim <filename>
即可进入一个文件(不论这个文件是否存在)的命令模式,输入wq
等底线命令可退出文件命令模式。
工作模式示意图
命令模式
输入
i o a
等可进到输入模式;输入
:
即可进入底线命令模式输入模式
除
Esc
键外,其他按键均为输入;按
Esc
键即可退出输入模式,进入到命令模式。底线命令模式
操作命令以
回车
结束底线命令模式;按
Esc
键即可退出输入模式,进入到命令模式。
2. 不同模式下的命令介绍
2.1 命令模式
移动光标
0
数字0,移动到这一行的最前面字符处$
移动到这一行的最后面字符处G
移动到这个文件的最后一行nG
n为整数,移动到这个文件的n行gg
移动到这个文件的第一行,相当于1G
n<Enter>
n为整数,以当前行为准,向下移动n行搜索替换 *
/word
光标之下搜索一个名称为word的字符串n
向下继续寻找上一步的搜索字符串内容N
向上继续寻找上一步的搜索字符串内容复制、粘贴和删除 **
x,X
x表示删除光标所在的后一个字符;X表示删除光标所在的前一个字符dd
删除光标所在的当前行ndd
n为整数,删除光标所在的向下n行(从光标所在行开始)yy
复制光标所在的当前行nyy
n为整数,复制光标所在的向下n行(从光标所在行开始)p,P
p为将已复制的数据粘贴到光标下一行, P则是粘贴到光标的上一行u
复原前一个动作Ctrl+r
重做上一个动作.
小数点,重复上一个动作
2.2 命令模式切换到输入模式的相关按钮
进入输入模式
i
从目前光标所在处输入I
当前所在行的第一个非空字符处输入a
从目前光标所在的下一个字符处开始输入A
当前所在行的最后一个字符处输入o
小写字母o,在目前光标所在的下一行处输入新的一行O
大写字母o,在目前光标所在的上一行处输入新的一行进入取代模式
r
取代光标所在的一个字符R
一直取代光标所在的文字,直到按下 ESC 为止退出输入模式
Esc
退出输入模式,回到命令模式
2.3 命令模式切换到底线命令模式
储存和退出文件等命令
:w
保存修改:q
退出vi编辑模式:wq
保存修改并退出vi编辑模式ZZ
大写的字母z,等同于:wq
,保存修改并退出vi编辑模式:<>!
命令后加!
号,表示强制的操作行号显示操作
:set nu
显示行号:set nonu
取消显示行号
参考文档
边栏推荐
- Logo special training camp Section V font structure and common design techniques
- 串口数据帧
- Feature scaling normalization
- [OpenGL] note 29 anti aliasing (MSAA)
- Erik baleog and Olaf, advanced area of misc in the attack and defense world
- Redis入门完整教程:HyperLogLog
- 攻防世界 MISC 進階區 Erik-Baleog-and-Olaf
- leetcode 72. Edit Distance 编辑距离(中等)
- Logo Camp d'entraînement section 3 techniques créatives initiales
- Talk about Middleware
猜你喜欢
LOGO特训营 第四节 字体设计的重要性
It is said that software testing is very simple, but why are there so many dissuasions?
攻防世界 MISC 进阶区 3-11
Redis入门完整教程:GEO
Redis入门完整教程:列表讲解
集群的概述与定义,一看就会
2022-07-04: what is the output of the following go language code? A:true; B:false; C: Compilation error. package main import “fmt“ func main() { fmt.Pri
攻防世界 MISC 进阶 glance-50
NFT insider 64: e-commerce giant eBay submitted an NFT related trademark application, and KPMG will invest $30million in Web3 and metauniverse
SPSS installation and activation tutorial (including network disk link)
随机推荐
剑指 Offer 68 - I. 二叉搜索树的最近公共祖先
[machine learning] handwritten digit recognition
安装人大金仓数据库
The table is backed up in ODPs. Why check m in the metabase_ Table, the logical sizes of the two tables are inconsistent, but the number of
The new version judges the code of PC and mobile terminal, the mobile terminal jumps to the mobile terminal, and the PC jumps to the latest valid code of PC terminal
Redis入门完整教程:键管理
Logo special training camp Section IV importance of font design
Redis的持久化机制
Redis入门完整教程:事务与Lua
About stack area, heap area, global area, text constant area and program code area
Talk about Middleware
Hit the core in the advanced area of misc in the attack and defense world
测试必会:BUG的分类及推进解决
MYSQL架构——用户权限与管理
Summary of index operations in mongodb
How to manage 15million employees easily?
[try to hack] wide byte injection
9 - class
leetcode 72. Edit distance edit distance (medium)
Sword finger offer 68 - I. nearest common ancestor of binary search tree