# 文本编辑器

常用的两个文本编辑器，nano和vim。

nano容易上手一点，简单编辑文本还是可以的，vim比较强大，配置比较麻烦。

```
# 安装nano
pkg install nano

# 安装vim，安装python3支持，一些插件可能需要python4支持，就可能需要自己编译了。
pkg install vim vim-python
```

nano快捷键：

```
Ctrl+K  #剪贴一整行
Ctrl+U  #粘贴文字
Ctrl+Y  #上一页
Ctrl+V  #下一页
Ctrl+Q #搜索，第二次搜索就匹配下一个文本
Ctrl+_ #跳行
Ctrl+C #显示行号，也可以nano -c 显示行号
Ctrl+O  #保存
Ctrl+X  #退出，如果你修改了文件，会要你输入保存文件名，直接确认即可
```

nano启动脚本\~/.nanorc。 可以设置语法高亮等等。

```
include /usr/share/nano/html.nanorc
include /usr/share/nano/sh.nanorc
```

更多内容参考：[nano编辑器](https://zsxwz.com/2020/04/26/)

vim快捷键比较多：

```
:q 退出
:q! 强制退出
:w 保存

P 粘贴文字(会从当前光标的前一个位置开始粘贴)
yw 复制单词
y0 拷贝光标位置至行首的字符
搜索
/**\c** 搜索的时候忽略大小写
/\n\n发现空行
N 前一个搜索到的字符
:set incsearch 输入字符的时候即刻搜索
:set hlsearch 开启高亮显示
:nohlsearch 去掉高亮显示
:noh 去掉高亮显示(简写)
. 重复上一个命令
\* 移动到光标所在单词的下一个同一个单词处
\# 移动到光标所在单词的上一个同一个单词处
% 选择对应匹配的Tag
```

更多快捷键可以参考：[vim快捷键](https://bbs.zsxwz.com/thread-3160.htm)

vim 启动脚本\~/.vimrc。

vim语法高亮，自动补全，代码检查，美化等等可以参考：

&#x20;[vim配置一份ide](https://zsxwz.com/2020/07/31/%e4%b8%80%e4%bb%bdvim%e9%85%8d%e7%bd%ae%e7%ae%80%e5%8d%95%e7%9a%84ide%e6%96%87%e4%bb%b6/)

[termux配置vim代码补全](https://bbs.zsxwz.com/thread-3168.htm)


---

# 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://termux-wiki.zsxwz.com/wen-ben-bian-ji-qi.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.
