暂时放弃 vim

使用 vim 也有四五年了,但是现在感觉 vim 还是造成了一些效率低下的情形。主要是对于各种功能支持不全,比如说

  1. 补全功能,总是不完全好用,而且标准库的文档也弹不出来,每个语言也不统一。
  2. 第三方插件支持不统一,比如说 tagbar 支持不了 TypeScript

2019-08 更新,vscode 总是把机器 hang 住,滚回 vim 了

一些 vim 小技巧



check if mapping is replaced

:verbose map <Key>

using map may cause infinite recursion!

force set syntax

# vim: set filetype=javascript


使用 Ctrl-C 而不是esc

window management

use ctrl-w r to swap pane


{selection}zf or zf{motion} for manual folding


Ctrl-O to go back to files
Ctrl-I to go to new files


delete blank lines


run python from vim

:w !python



不要使用chardet来检测过长的网页,可以检测前一千个字符 chardet.detect(text[:1000])


:%!awk ‘{print $2, $1}’

:set fileencoding=utf8
:w myfilename

add utf-8 BOM

:set bomb # add BOMB

basic usage

:set spell to open, :set nospell to disable, :set spell! to toggle.

]s and [s to go to next and previous spell error. z= to see suggestions, but it’s not good. use :nnoremap \s ea<C-X><C-S>

Use set spell to check spellings in vim, if you find word marked wrongly, simple press zg to add it the dictionary and zw to remove it from the dictionary, they can be revoked with zug and zuw.
Use ]s to go forward in the highlighted errors and [s to go backwards.
Use z= to bring up suggestions

[1] Vim cast on spell check

zg       Add word under the cursor as a good word to the first
         name in "spellfile".  A count may precede the command
         to indicate the entry in "spellfile" to be used.  A
         count of two uses the second entry.

         In Visual mode the selected characters are added as a
         word (including white space!).
         When the cursor is on text that is marked as badly
         spelled then the marked text is used.
         Otherwise the word under the cursor, separated by
         non-word characters, is used.

         If the word is explicitly marked as bad word in
         another spell file the result is unpredictable.

zG       Like "zg" but add the word to the internal word list

zw       Like "zg" but mark the word as a wrong (bad) word.
         If the word already appears in "spellfile" it is
         turned into a comment line.  See |spellfile-cleanup|
         for getting rid of those.

zW       Like "zw" but add the word to the internal word list

zug      Undo |zw| and |zg|, remove the word from the entry in
         "spellfile".  Count used as with |zg|.

zuG      Undo |zW| and |zG|, remove the word from the internal
         word list.  Count used as with |zg|.

vim 中生成和使用 tags

To use go to definition and other advanced IDE feature, we need to generate tag files for vim to figure out where to find the functions or variables.

To generate a tag file

ctags -R

By default, the generate tag file will be located at ./tags directory, we need to let vim know where to find it by:

:set tags+=tags

To search for a symbol in vim, use

:tag [symbol-name]
:tag /[search-name]

To go to the definition, we need Ctrl-], to go back, press Ctrl-t

:tn next tag
:tp prev tag
:ts all tags



vim tags matchlist is not very user friendly. I should write my own that shows the list in quick fix window