felix-cao / Blog

A little progress a day makes you a big success!
31 stars 4 forks source link

Vim 使用技巧 #196

Closed felix-cao closed 3 years ago

felix-cao commented 3 years ago

显示行号

:set nu, 回车

跳转到指定行

:n, 回车 n表示该文件的第n行,

跳到最后一行

shift + g

搜索字符串

/string

string 为要搜索的字符串, 多个结果时,查看下一个匹配,按下n(小写n),跳转到上一个匹配,按下N(大写N)

删除以 # 开头的注释内容

:g/^#/d

删除所有空行

:g/^$/d

多行行首加入“#”

:n1,n2s/^/#/g n1到n2行行首加入“#” “^”符号代表的是行首 “g”表示不确认 :n1,n2s/^#//g n1到n2行行首开始的“#”去掉