You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
1.9 KiB
84 lines
1.9 KiB
3 years ago
|
---
|
||
|
title: VIM 编辑器
|
||
|
date: 2020-10-18
|
||
|
categories:
|
||
|
- linux
|
||
|
tags: [linux]
|
||
|
---
|
||
|
|
||
|
|
||
|
## VIM 文本编辑器
|
||
|
> 一般 `linux` 系统上默认都会安装 `vim` 文本编辑器。
|
||
|
|
||
|
|
||
|
|
||
|
## 快捷操作
|
||
|
|
||
|
### 批量添加注释
|
||
|
|
||
|
> 有两种方法:
|
||
|
|
||
|
#### 使用可视模式
|
||
|
|
||
|
##### 注释
|
||
|
|
||
|
1. 按 **`Ctrl+ v`** 进入块选择模式,
|
||
|
|
||
|

|
||
|
|
||
|
|
||
|
2. 然后移动光标选中你要注释的行,
|
||
|
|
||
|

|
||
|
|
||
|
|
||
|
3. 再按大写的 **`I`** 进入首行插入模式,输入注释符号比如 `#`,
|
||
|
|
||
|

|
||
|
|
||
|
|
||
|
4. 输入完成后,按 **两下** `ESC`, vim 会自动将你选中的行都加上注释,保存退出
|
||
|
|
||
|

|
||
|
|
||
|
|
||
|
##### 取消注释
|
||
|
|
||
|
1. **`Ctrl + v`** 进入块选择模式,
|
||
|
|
||
|

|
||
|
|
||
|
2. 选中你要删除的行首的注释符号,
|
||
|
|
||
|

|
||
|
|
||
|
3. 选好之后按 **d** 即可删除注释,**ESC** 保存退出。
|
||
|
|
||
|

|
||
|
|
||
|
|
||
|
|
||
|
#### 使用替换命令
|
||
|
|
||
|
##### 注释
|
||
|
|
||
|
使用下面命令在指定的行首添加注释。
|
||
|
|
||
|
使用名命令格式: **`:起始行号,结束行号s/^/注释符/g`**
|
||
|
|
||
|

|
||
|
|
||
|
|
||
|
|
||
|

|
||
|
|
||
|
##### 取消注释
|
||
|
|
||
|
使用名命令格式: **`:起始行号,结束行号s/^注释符//g`**
|
||
|
|
||
|

|
||
|
|
||
|

|
||
|
|
||
|
|