1 Commits

Author SHA1 Message Date
Wang Shidong
2b27bec9b5 Add tips
close #39
2019-04-06 19:31:32 +08:00
5 changed files with 76 additions and 73 deletions

View File

@@ -42,9 +42,9 @@
- [TeX](#tex)
- [VimL](#viml)
## 颜色主题
## Colorschemes
以下为一些比较流行的颜色主题:
Here's a list of commonly used colorschemes:
- [acme-colors](https://github.com/plan9-for-vimspace/acme-colors)
- [apprentice](https://github.com/romainl/Apprentice)
@@ -69,21 +69,21 @@
Alternatively, generate your own colorscheme using [themer](https://github.com/mjswensen/themer)
or [Colortemplate](https://github.com/lifepillar/vim-colortemplate).
## 按功能分类
## By topic
#### 文本对齐
#### Alignment
- [tabular](https://github.com/godlygeek/tabular)
- [vim-easy-align](https://github.com/junegunn/vim-easy-align)
- [vim-lion](https://github.com/tommcdo/vim-lion)
#### 语法检查
#### Building and linting
- [ale](https://github.com/w0rp/ale)
- [neomake](https://github.com/neomake/neomake)
- [syntastic](https://github.com/vim-syntastic/syntastic)
#### 代码补全
#### Code completion
- [asyncomplete.vim](https://github.com/prabirshrestha/asyncomplete.vim)
- [completor.vim](https://github.com/maralla/completor.vim)
@@ -100,19 +100,19 @@ or [Colortemplate](https://github.com/lifepillar/vim-colortemplate).
- [switch.vim](https://github.com/AndrewRadev/switch.vim)
- [vim-speeddating](https://github.com/tpope/vim-speeddating)
#### 代码注释
#### Commenters
- [nerdcommenter](https://github.com/scrooloose/nerdcommenter)
- [tcomment_vim](https://github.com/tomtom/tcomment_vim)
- [vim-commentary](https://github.com/tpope/vim-commentary)
#### 自动补全括号
#### Delimiter
- [auto-pairs](https://github.com/jiangmiao/auto-pairs)
- [delimitMate](https://github.com/Raimondi/delimitMate)
- [vim-endwise](https://github.com/tpope/vim-endwise)
#### 模糊搜索
#### Fuzzy finders
- [Command-T](https://github.com/wincent/Command-T) (_requires +ruby_)
- [ctrlp.vim](https://github.com/ctrlpvim/ctrlp.vim)
@@ -121,13 +121,13 @@ or [Colortemplate](https://github.com/lifepillar/vim-colortemplate).
- [unite.vim](https://github.com/Shougo/unite.vim)
- [vim-fz](https://github.com/mattn/vim-fz)
#### 文本搜索
#### Grep tools
- [ctrlsf.vim](https://github.com/dyng/ctrlsf.vim)
- [ferret](https://github.com/wincent/ferret)
- [vim-grepper](https://github.com/mhinz/vim-grepper)
#### 代码对齐线
#### Indent
- [indentLine](https://github.com/Yggdroot/indentLine)
- [vim-indent-guides](https://github.com/nathanaelkane/vim-indent-guides)
@@ -144,7 +144,7 @@ or [Colortemplate](https://github.com/lifepillar/vim-colortemplate).
Also see [fuzzy finders](#fuzzy-finders).
#### 插件管理
#### Plugin managers
- [apt-vim](https://github.com/egalpin/apt-vim)
- [dein.vim](https://github.com/Shougo/dein.vim)
@@ -154,14 +154,14 @@ Also see [fuzzy finders](#fuzzy-finders).
- [vim-plug](https://github.com/junegunn/vim-plug)
- [vundle.vim](https://github.com/VundleVim/Vundle.vim)
#### 代码片段
#### Snippets
- [neosnippet.vim](https://github.com/Shougo/neosnippet.vim) (_depends on other plugins_)
- [ultisnips](https://github.com/SirVer/ultisnips)
- [vim-snipmate](https://github.com/garbas/vim-snipmate) (_depends on other plugins_)
- [xptemplate](https://github.com/drmingdrmer/xptemplate)
#### 状态栏
#### Statusline
- [lightline.vim](https://github.com/itchyny/lightline.vim)
- [powerline](https://github.com/powerline/powerline)
@@ -187,7 +187,7 @@ Also see [fuzzy finders](#fuzzy-finders).
- [vim-test](https://github.com/janko-m/vim-test)
#### 文本对象
#### Text objects
- [targets.vim](https://github.com/wellle/targets.vim)
- [vim-exchange](https://github.com/tommcdo/vim-exchange)
@@ -258,9 +258,9 @@ Also see [fuzzy finders](#fuzzy-finders).
- [vim-startify](https://github.com/mhinz/vim-startify)
- [vim-unimpaired](https://github.com/tpope/vim-unimpaired)
## 编程语言
## By filetype
#### CC++
#### C and C++
- [a.vim](https://github.com/vim-scripts/a.vim)
- [clang_complete](https://github.com/Rip-Rip/clang_complete)

View File

@@ -74,9 +74,6 @@
- [禁用错误报警声音和图标](#禁用错误报警声音和图标)
- [快速移动当前行](#快速移动当前行)
- [快速添加空行](#快速添加空行)
- [运行时检测](#运行时检测)
- [查看启动时间](#查看启动时间)
- [NUL 符用新行表示](#nul-符用新行表示)
- [快速编辑自定义宏](#快速编辑自定义宏)
- [快速跳转到源(头)文件](#快速跳转到源头文件)
- [在 GUI 中快速改变字体大小](#在-gui-中快速改变字体大小)
@@ -110,6 +107,7 @@
- [持续粘贴(为什么我每次都要设置 'paste' 模式)](#持续粘贴为什么我每次都要设置-paste-模式)
- [在终端中按 ESC 后有延时](#在终端中按-esc-后有延时)
- [无法重复函数中执行的搜索](#无法重复函数中执行的搜索)
- [插件列表](#插件列表)
- [进阶阅读](#进阶阅读)
- [加入我们](#加入我们)
@@ -143,10 +141,8 @@ Vim 采用模式编辑的理念,即它提供了多种模式,按键在不同
但是这有一个很大的优点:不需要通过同时按住多个键来完成操作,
大多数时候你只需要依次按下这些按键即可。越常用的操作,所需要的按键数量越少。
和模式编辑紧密相连的概念是 **操作符****动作**。**操作符** 指的是开始某个行为,
例如:修改、删除或者选择文本,之后你要用一个 **动作** 来指定需要操作的文本区域
比如,要改变括号内的文本,需要执行 `ci(` (读做 `change inner parentheses`
删除整个段落的内容,需要执行 `dap` (读做:`delete around paragraph`)。
和模式编辑紧密相连的概念是“操作符”和“动作”。_操作符_ 开始一些行为,例如:修改,删除,或者选择文本。之后你要用一个 _动作_ 来指定需要操作的文本区域。比如,要改变括号内的文本,需要执行 `ci(` (读做 _change inner parentheses_);删除整个段落的内容,需要执行 `dap` 读做_delete
around paragraph_
如果你能看见 Vim 老司机操作,你会发现他们使用 Vim 脚本语言就如同钢琴师弹钢琴一样。复杂的操作只需要几个按键就能完成。他们甚至不用刻意去想,因为这已经成为[肌肉记忆](https://en.wikipedia.org/wiki/Muscle_memory)了。这减少[认识负荷](https://en.wikipedia.org/wiki/Cognitive_load)并帮助人们专注于实际任务。
@@ -1495,47 +1491,6 @@ nnoremap ]<space> :<c-u>put =repeat(nr2char(10), v:count1)<cr>
设置之后,连续按下 <kbd>5</kbd> <kbd>\[</kbd> <kbd>空格</kbd> 在当前行上方插入 5 个空行。
### 运行时检测
需要的特性:+profile
Vim 提供了一个内置的运行时检查功能,能够找出运行慢的代码。
`:profile` 命令后面跟着子命令来确定要查看什么。
如果你想查看所有的:
```Vim
:profile start /tmp/profile.log
:profile file *
:profile func *
<do something in Vim>
<quit Vim>
```
Vim 不断地在内存中检查信息只在退出的时候输出出来。Neovim 已经解决了这个问题用 `:profile dump` 命令)
看一下 `/tmp/profile.log` 文件,检查时运行的所有代码都会被显示出来,包括每一行代码运行的频率和时间。
大多数代码都是用户不熟悉的插件代码,如果你是在解决一个确切的问题,
直接跳到这个日志文件的末尾,那里有 `FUNCTIONS SORTED ON TOTAL TIME` 和 `FUNCTIONS SORTED ON SELF TIME` 两个部分如果某个function运行时间过长一眼就可以看到。
### 查看启动时间
感觉Vim启动的慢到了研究几个数字的时候了
```vim
vim --startuptime /tmp/startup.log +q && vim /tmp/startup.log
```
第一栏是最重要的因为它显示了**绝对运行时间**如果在前后两行之间时间差有很大的跳跃那么是第二个文件太大或者含有需要检查的错误的VimL代码。
## NUL 符用新行表示
文件中的 NUL 符 `\0`),在内存中被以新行(`\n`)保存,在缓存空间中显示为 `^@`。
更多信息请参看 `man 7 ascii` 和 `:h NL-used-for-Nul` 。
## 快速编辑自定义宏
这个功能真的很实用!下面的映射,就是在一个新的命令行窗口中读取某一个寄存器(默认为 `*`)。当你设置完成后,只需要按下 <kbd>回车</kbd> 即可让它生效。
@@ -1605,6 +1560,18 @@ xnoremap > >gv
设置好之后,在可视模式中使用 `>>>>>` 就不会再出现上面提到的问题了。
## 选择当前行至结尾,排除换行符
在 Vim 里,我们可以同过 `v$` 选择当前行至结尾,但此时会把最后一个换行符也选中,通常需要按额外的 `h` 来取消最后选中最后一个换行符号。
Vim 提供了一个 `g_` 快捷键,可以移动光标至最后一个非空字符。因此,为达到次效果,可以使用 `vg_`。当然,如果觉得按三个键比较麻烦,
可以添加一个映射:
```vim
nnoremap L g_
```
这样就可以通过 `vL` 达到一样的效果了。
## 重新载入保存文件
通过[自动命令](#自动命令),你可以在保存文件的同时触发一些其他功能。比如,如果这个文件是一个配置文件,那么就重新载入;或者你还可以对这个文件进行代码风格检查。
@@ -1848,14 +1815,6 @@ Vim 现在正在使用的另一个比较有用的方法是增加 debug 信息输
## Vim 配置集合
目前,网上有很多流行 Vim 配置集合,对于 Vim 配置集合,个人认为有利有弊。
对于维护的比较好的配置,比如 [SpaceVim](http://spacevim.org/cn/) 还是值得尝试的,可以节省很多自行配置的时间。
当然,网上还有很多其他很流行的配置,比如:
- [k-vim](https://github.com/wklken/k-vim)
- [amix's vimrc](https://github.com/amix/vimrc)
- [janus](https://github.com/carlhuda/janus)
## 内置插件
## 将 Control 映射到 CapsLock
@@ -1975,6 +1934,8 @@ set ttimeoutlen=10 " unnoticeable small value
帮助文档:`:h function-search-undo`
## [插件列表](PLUGINS.md)
## 进阶阅读
- [Vim 插件开发指南](https://github.com/wsdjeg/vim-plugin-dev-guide)
@@ -1982,3 +1943,7 @@ set ttimeoutlen=10 " unnoticeable small value
## 加入我们
可以协助我们核对翻译,或者从[章节列表](CONTRIBUTING.md)中认领章节进行翻译。
## 参考资料
- [Nifty Little Nvim Techniques to Make My Life Easier -- Series 1](https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/)

View File

@@ -0,0 +1,23 @@
### 运行时检测
需要的特性:+profile
Vim 提供了一个内置的运行时检查功能,能够找出运行慢的代码。
```:profile``` 命令后面跟着子命令来确定要查看什么。
如果你想查看所有的:
```Vim
:profile start /tmp/profile.log
:profile file *
:profile func *
<do something in Vim>
<quit Vim>
```
Vim 不断地在内存中检查信息只在退出的时候输出出来。Neovim 已经解决了这个问题用 ```:profile dump``` 命令)
看一下 ```/tmp/profile.log``` 文件,检查时运行的所有代码都会被显示出来,包括每一行代码运行的频率和时间。
大多数代码都是用户不熟悉的插件代码,如果你是在解决一个确切的问题,直接跳到这个日志文件的末尾,那里有 ```FUNCTIONS SORTED ON TOTAL TIME``` 和 ```FUNCTIONS SORTED ON SELF TIME``` 两个部分如果某个function运行时间过长一眼就可以看到。

View File

@@ -0,0 +1,10 @@
### 查看启动时间
感觉Vim启动的慢到了研究几个数字的时候了
```vim
vim --startuptime /tmp/startup.log +q && vim /tmp/startup.log
```
第一栏是最重要的因为它显示了**绝对运行时间**如果在前后两行之间时间差有很大的跳跃那么是第二个文件太大或者含有需要检查的错误的VimL代码。

View File

@@ -0,0 +1,5 @@
## NUL 符用新行表示
文件中的 NUL 符 `\0`),在内存中被以新行(`\n`)保存,在缓存空间中显示为 `^@`
更多信息请参看 `man 7 ascii``:h NL-used-for-Nul`