当前位置:网站首页>vim基础操作汇总
vim基础操作汇总
2022-07-25 13:02:00 【就要 宅在家】
vim是linux下一款文件编辑器,本篇文章小编将重点汇总普通模式下的操作以及模式之间的转换。
目录
一.模式转换及退出
(一).模式转换
在默认情况下,vim编辑器是普通模式(normal)

vim有五大基本模式:普通模式、插入模式(insert)、替换模式(replace)、命令模式(command)、可视模式(visual)。
替换方式如下:
| 普通->插入 | i |
| 普通->替换 | R |
| 普通->命令 | : |
| 普通->可视 | v |
| 其他模式->普通 | Esc |
值得注意的是,如果我们想让两个非普通模式相互切换,需要先转到普通模式再进行对应切换。
可以用下表做总结:

(二).退出
退出时,我们要使用命令模式,在命令模式下:
| w | 保存 | wq | 保存并退出 |
| q | 退出 | w! | 强制保存 |
| ! | 强制 | q! | 强制退出 |

此时按回车键即可退出。
二.普通模式下的vim操作及分屏切换
(一).普通模式下的vim操作
在普通模式下,我们进行指令操作不需要使用回车键。
注意:以下可以不写n,无n均默认为1。
| n yy | 从光标开始复制n行。 |
| n p | 从光标下一行开始粘贴n次。 |
| n u | 撤销n次历史操作。 |
| n ctrl r / ctrl R | 撤销刚才的u操作。 |
| n G | 光标定位到第n行,无n则定至末行 |
| n gg | 光标定位到第n行,无n则定至首行 |
| n w | 光标以单词为单位右移n个。 |
| n b | 光标以单词为单位左移n个。 |
| n $ / shift 4 | 算上本行光标下移4行。无n光标移至本行最右列 |
| ^ / shift 6 | 光标移至本行最左列 |
| n dd | 将n行剪切,也可当作删除。 |
| n r | 替换n个字符(将n个字符替换成同一个)。 |
| n x | 删除n个字符(从左至右)。 |
| n X | 删除n个字符(从右至左)。 |
| n ~ / shift ` | 将光标起n个字符大小写转换。 |
(二).分屏切换
分屏切换需要在命令模式中进行。
竖直分屏:vs 文件
水平分屏:sp 文件
切换分屏:ctrl ww
vim下进行linux指令操作:! 指令
退出分屏:exit (此时光标位于哪个文件就退出哪个文件)
- “愚者困惑,智者提问。”——本杰明·迪斯雷利(Benjamin Disraeli)
如有错误,敬请斧正
边栏推荐
- Mlx90640 infrared thermal imager temperature sensor module development notes (V)
- 【历史上的今天】7 月 25 日:IBM 获得了第一项专利;Verizon 收购雅虎;亚马逊发布 Fire Phone
- 零基础学习CANoe Panel(15)—— 文本输出(CAPL Output View )
- 零基础学习CANoe Panel(16)—— Clock Control/Panel Control/Start Stop Control/Tab Control
- R语言GLM广义线性模型:逻辑回归、泊松回归拟合小鼠临床试验数据(剂量和反应)示例和自测题
- [machine learning] experimental notes - emotion recognition
- 工业互联网的内涵及其应用
- [ai4code final chapter] alphacode: competition level code generation with alphacode (deepmind)
- Zero basic learning canoe panel (12) -- progress bar
- 牛客论坛项目部署总结
猜你喜欢

ESP32-C3 基于Arduino框架下Blinker点灯控制10路开关或继电器组

VIM tip: always show line numbers

A turbulent life

Zero basic learning canoe panel (14) -- led control and LCD control

Shell common script: get the IP address of the network card

Django 2 ----- 数据库与Admin

【CSDN 年终总结】结束与开始,一直在路上—— “1+1=王”的2021总结

mysql函数汇总之日期和时间函数
![[operation and maintenance, implementation of high-quality products] interview skills for technical positions with a monthly salary of 10k+](/img/d8/90116f967ef0f5920848eca1f55cdc.png)
[operation and maintenance, implementation of high-quality products] interview skills for technical positions with a monthly salary of 10k+

cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘
随机推荐
Date and time function of MySQL function summary
[CSDN year-end summary] end and start, always on the way - "2021 summary of" 1+1= Wang "
VIM tip: always show line numbers
cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘
Excel import and export source code analysis
word样式和多级列表设置技巧(二)
2022 年中回顾 | 大模型技术最新进展 澜舟科技
[机器学习] 实验笔记 – 表情识别(emotion recognition)
485 communication (detailed explanation)
Mid 2022 review | latest progress of large model technology Lanzhou Technology
牛客论坛项目部署总结
[ai4code final chapter] alphacode: competition level code generation with alphacode (deepmind)
massCode 一款优秀的开源代码片段管理器
A hard journey
错误: 找不到或无法加载主类 xxxx
Convolutional neural network model -- lenet network structure and code implementation
"Autobiography of Franklin" cultivation
[today in history] July 25: IBM obtained the first patent; Verizon acquires Yahoo; Amazon releases fire phone
【AI4Code】《Pythia: AI-assisted Code Completion System》(KDD 2019)
Zero basic learning canoe panel (15) -- CAPL output view