# Vim 实操教程（Learning Vim）

[English](/learn-vim/en.md) | [简体中文](/learn-vim/zh-cn.md)

## 引言

以我个人学习 Vim 的经验来看，通过看文档或看其他人操作其实是很难真正学会 Vim 的， 你必须在实际应用中，进入真实场景才能逐渐熟悉并掌握相关命令。

因此，为了同时满足学习和操作的需求，项目中的文件都采用了 Markdown 格式，既可以当 作说明文档来阅读，也可以用 Vim 打开文件进行实际操作（建议采用后者）。

## 如何使用

1. clone 项目到本地

```bash
git clone https://github.com/dofy/learn-vim.git
```

2. 进入项目文件夹

```bash
cd learn-vim/zh-CN
```

3. 用 Vim 打开文件 `chapter01.md`

```bash
vim chapter01.md
```

## 排版规范

```markdown

## 大标题表示一大类

### 小标题表示该大类下的小分类

没有任何格式的文本为正常描述，只有阅读功能。

> 嵌入到引用块中的文本为操作指示，你可以按照里面提到的内容进行操作
>
> 同时操作符或命令会包含在类似 `:w` 的符号中

命令中形如 f<X> 中的 < 和 > 不需要打出来，<X> 代表一个变量，即你可以打 fa 或 fb
亦或 fC

_注意：命令区分大小写（需要注意的事项会出现在当前行这样的符号中）_

```

> \[!NOTE]
>
> 如果你已经有了自己的 `.vimrc` 文件 (参考 [第四章](/learn-vim/zh-cn/chapter04.md)) 并在其中修改 了一些默认设置，那么可能导致某些操作与教程不符。如遇此情况，你可以用下面的命令 来运行 `Vim`：
>
> ```bash
> # 不加载配置文件
> vim -u NONE
> # 加载特定配置文件
> vim -u <filename>
> ```

## 导航

### 基础操作

1. [第一章：光标的移动](/learn-vim/zh-cn/chapter01.md)
2. [第二章：打开文件、查找内容](/learn-vim/zh-cn/chapter02.md)
3. [第三章：文档的修改与保存](/learn-vim/zh-cn/chapter03.md)
4. [第四章：一些小技巧](/learn-vim/zh-cn/chapter04.md)
5. [第五章：分屏与标签页](/learn-vim/zh-cn/chapter05.md)
6. [第六章：块操作](/learn-vim/zh-cn/chapter06.md)
7. [第七章：Vim 中的宏](/learn-vim/zh-cn/chapter07.md)

### 附加内容

1. [Vim 的模式](/learn-vim/zh-cn/vim-modes.md)
2. [Vim 插件](/learn-vim/zh-cn/vim-plugin.md)
3. [插件推荐](/learn-vim/zh-cn/plugins/index.md)
   1. [NERDTree](/learn-vim/zh-cn/plugins/nerdtree.md)
   2. [EasyAlign](/learn-vim/zh-cn/plugins/easyalign.md)
   3. [Airline & Themes](/learn-vim/zh-cn/plugins/airline.md)
   4. [surround.vim](/learn-vim/zh-cn/plugins/surround.md)

> \[!NOTE]
>
> * 教程中会有下一章或相关章节的导航，定位到文件名执行 `gf`（goto file）就可以打 开相关文件
> * 你可以随时打开相关章节查看，然后用 `:bp` 回到之前的文件（该命令会 在[第二章](/learn-vim/zh-cn/chapter02.md)中讲到）
> * 当你用 `:q` 或 `:qa` 退出教程时可能会收到文件未保存的错误提醒，试试在命令后 面加上 `!`

## 推荐几个 Vim 配置方案

* [dofy / **7th-vim**](https://github.com/dofy/7th-vim)
* [kepbod / **ivim**](https://github.com/kepbod/ivim)
* [chxuan / **vimplus**](https://github.com/chxuan/vimplus)
* [SpaceVim / **SpaceVim**](https://github.com/SpaceVim/SpaceVim)

## 推荐另外几个出色的 Vim 教程

* 控制台运行 `vimtutor` 这是 Vim 官方实操教程
* [简明 Vim 练级攻略](https://coolshell.cn/articles/5426.html) 很不错的入门教程
* [Vim Galore](https://github.com/mhinz/vim-galore) 更新频繁，Vim 进阶必读
* [每日一 Vim](http://liuzhijun.iteye.com/category/270228) 共 30 篇，内容比较全
* [A book for learning the Vim editor](https://github.com/iggredible/Learn-Vim) 另一个 Learn Vim （英语）
* [Open Vim](https://openvim.com/) 交互式 Vim 教程
* [QuickRef.ME/vim](https://quickref.me/vim) Vim cheatsheet

## Cheatsheets

> [Vim Cheat Sheet](https://vim.rtorr.com/lang/zh_tw)

> [A Great Vim Cheat Sheet](https://vimsheet.com/)

> [![003](https://people.csail.mit.edu/vgod/vim/vim-cheat-sheet-en.png)](https://people.csail.mit.edu/vgod/vim/vim-cheat-sheet-en.png)

> [![004](https://cdn.shopify.com/s/files/1/0165/4168/files/preview.png)](https://cdn.shopify.com/s/files/1/0165/4168/files/preview.png)

> [![005](https://raw.githubusercontent.com/Michaelangel007/vim_cheat_sheet/master/vim_cheat_sheet_for_programmers_print_150dpi.png)](https://raw.githubusercontent.com/Michaelangel007/vim_cheat_sheet/master/vim_cheat_sheet_for_programmers_print_150dpi.png)

**再次感谢您的关注！如果爱，请分享。爱生活，爱 VIM！**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dofy.gitbook.io/learn-vim/zh-cn.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
