$ ls ~yifei/notes/

一些 vim 小技巧

Posted on:

Last modified:

重新对齐文本到固定长度

gq<motion>

check if mapping is replaced

:verbose map <Key>

using map may cause infinite recursion!

force set syntax

# vim: set filetype=javascript

exit

使用 Ctrl-C 而不是 esc 使用 ZZ 而不是:wq

window management

use ctrl-w r to swap pane

folding

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

history

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

:%s/pattern//gn

delete blank lines

:g/^$/d

run python from vim

:w !python

nerdtree 的使用

使用 i 和 s 分别在 split 中打开文件

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

交换两列

:%!awk '{print $2, $1}'

:set fileencoding=utf8 :w myfilename

add utf-8 BOM

:set bomb # add BOMB

参考

  1. https://www.cs.oberlin.edu/~kuperman/help/vim/variables.html
  2. https://castel.dev/post/lecture-notes-1/

© 2016-2022 Yifei Kong. Powered by ynotes

All contents are under the CC-BY-NC-SA license, if not otherwise specified.

Opinions expressed here are solely my own and do not express the views or opinions of my employer.