当前位置:网站首页>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)
如有错误,敬请斧正
边栏推荐
- 【AI4Code】CodeX:《Evaluating Large Language Models Trained on Code》(OpenAI)
- Use vsftpd service to transfer files (anonymous user authentication, local user authentication, virtual user authentication)
- Force deduction 83 biweekly T4 6131. The shortest dice sequence impossible to get, 303 weeks T4 6127. The number of high-quality pairs
- 牛客论坛项目部署总结
- 卷积神经网络模型之——LeNet网络结构与代码实现
- 迁移PaloAlto HA高可用防火墙到Panorama
- Zero basic learning canoe panel (13) -- trackbar
- Shell Basics (exit control, input and output, etc.)
- [ai4code final chapter] alphacode: competition level code generation with alphacode (deepmind)
- 机器学习强基计划0-4:通俗理解奥卡姆剃刀与没有免费午餐定理
猜你喜欢

【GCN-RS】Towards Representation Alignment and Uniformity in Collaborative Filtering (KDD‘22)

Docekr学习 - MySQL8主从复制搭建部署

cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘

The larger the convolution kernel, the stronger the performance? An interpretation of replknet model

【AI4Code】《Unified Pre-training for Program Understanding and Generation》 NAACL 2021

【问题解决】ibatis.binding.BindingException: Type interface xxDao is not known to the MapperRegistry.

Eccv2022 | transclassp class level grab posture migration

Chapter5 : Deep Learning and Computational Chemistry

零基础学习CANoe Panel(12)—— 进度条(Progress Bar)
![[CSDN year-end summary] end and start, always on the way -](/img/51/a3fc5eba0eeb22b600260ee81ff9e6.png)
[CSDN year-end summary] end and start, always on the way - "2021 summary of" 1+1= Wang "
随机推荐
"Wei Lai Cup" 2022 Niuke summer multi school training camp 2 supplementary problem solution (g, J, K, l)
Redis可视化工具RDM安装包分享
一味地做大元宇宙的规模,已经背离了元宇宙本该有的发展逻辑
手写一个博客平台~第一天
好友让我看这段代码
零基础学习CANoe Panel(12)—— 进度条(Progress Bar)
Shell common script: judge whether the file of the remote host exists
Microsoft proposed CodeT: a new SOTA for code generation, with 20 points of performance improvement
【问题解决】org.apache.ibatis.exceptions.PersistenceException: Error building SqlSession.1 字节的 UTF-8 序列的字
Azure Devops(十四) 使用Azure的私有Nuget仓库
Clickhouse notes 03-- grafana accesses Clickhouse
详解浮点数的精度问题
【GCN-RS】Learning Explicit User Interest Boundary for Recommendation (WWW‘22)
Machine learning strong foundation program 0-4: popular understanding of Occam razor and no free lunch theorem
A turbulent life
Memory layout of program
VIM tip: always show line numbers
485 communication (detailed explanation)
ECCV 2022 | 登顶SemanticKITTI!基于二维先验辅助的激光雷达点云语义分割
Zero basic learning canoe panel (13) -- trackbar