当前位置:网站首页>Vim编辑器的最常用的用法
Vim编辑器的最常用的用法
2022-06-24 15:33:00 【独家雨天】
Vim中有3中使用模式:这3种模式的切换可以用下面的一张图来说明

命令模式
在使用Vim 命令的时候,默认进入命令模式。命令模式通常,都进行一些整行的操作。主要包含的命令如下:
| 命令 | 作用 |
|---|---|
| dd | 删除(剪切)光标所在整行 |
| 5dd | 删除(剪切)从光标处开始的5行 |
| yy | 复制光标所在整行 |
| 5yy | 复制从光标处开始的5行 |
| n | 显示搜索命令定位到的下一个字符串 |
| N | 显示搜索命令定位到的上一个字符串 |
| u | 撤销上一步的操作 |
| p | 将之前删除(dd)或复制(yy)过的数据粘贴到光标后面 |
还很常用的就是,使用G可以直接跳转到最后一行,gg可以到首行。
输入(编辑)模式
主要就3个输入方式:
- a(append追加的意思)表示在当前鼠标的后面一位插入
- i (Insert插入的意思)表示在当前鼠标的当前位置插入
- o(另起一行的意思)表示在鼠标所在行,下一行插入
末行模式
主要用于保存或退出文件,以及设置 Vim 编辑器的工作环境,还可以让用户执行外部的 Linux 命令或跳转到所编写文档的特定行数。
最常用的命令:
:wq保存并退出:q不保存退出,:q!强制退出,放弃所有保存
| 命令 | 作用 |
|---|---|
| :set nu | 显示行号 |
| :set nonu | 不显示行号 |
| :命令 | 执行该命令 |
| :整数 | 跳转到该行 |
| /one/two | 将当前光标所在行的第一个 one 替换成 two |
| /one/two/g | 将当前光标所在行的所有 one 替换成 two |
| :%s/one/two/g | 将全文中的所有 one 替换成 two |
| ?字符串 | 在文本中从下至上搜索该字符串 |
| /字符串 | 在文本中从上至下搜索该字符串 |
如果想查看,在所有的文档中,可以通过vim命令重新进入,或者cat输出文件内容。
边栏推荐
- Tencent cloud native intelligent data Lake Conference will be held, revealing the panoramic matrix of Tencent cloud data Lake products for the first time
- Is financial management of securities account safe??
- 运营商5G用户渗透远远比4G慢,5G的普及还得看中国广电
- Cvpr2022 | domaine compact adaptable
- Record the range of data that MySQL update will lock
- 东方财富哪个开户更安全,更好点
- List of PostgreSQL
- Design of vga/lcd display controller system based on FPGA (Part 2)
- 高速公路服务区智能一体机解决方案
- As a developer, what is the most influential book for you?
猜你喜欢
Oracle RAC configuration multipathing

推荐几款超级实用的数据分析利器

还在担心漏测吗?快来使用jacoco统计下代码覆盖率

Linux记录-4.22 MySQL5.37安装(补充)

熬夜整理出的软件测试【高频】面试题大全(2022最新)

Do you really know the difference between H5 and applet?

List of PostgreSQL

Wi-Fi 7 来啦,它到底有多强?
![clang: warning: argument unused during compilation: ‘-no-pie‘ [-Wunused-command-line-argument]](/img/f0/42f394dbc989d381387c7b953d2a39.jpg)
clang: warning: argument unused during compilation: ‘-no-pie‘ [-Wunused-command-line-argument]

【C语言刷题——Leetcode12道题】带你起飞,飞进垃圾堆
随机推荐
【Prometheus】6. Prometheus and kubernetes (incomplete)
How to optimize performance
How to build a high-performance go cache Library
This website teaches you to imitate more than 100 well-known websites!
Working with collections
高速公路服务区智能一体机解决方案
国产最长寿的热销手机,苹果也不是对手,总算让国产手机找回面子
股票网上开户及开户流程怎样?网上开户安全么?
Which securities company is better and safer for great wisdom to choose when opening an account
Redis consistency hash and hash slot
Precautions for using JMeter suite to build a pressure test environment
asciinema 搭配 asciicast2gif 实现高效的命令行终端录制能力
手机注册股票开户 炒股开户安全吗
Do you really know the difference between H5 and applet?
Is it safe for futures companies to open accounts
Decomposition of Uber dependency injection into dig source code analysis
Allwinner a40i industrial Internet gateway design scheme, smart site, smart city core gateway
Concurrent writing of maps in golang
[log service CLS] a taste of Tencent cloud log service CLS
Low fidelity prototype vs high fidelity prototype, which one is more suitable for your design?