vi相关

列模式下插入:Ctrl + i

列模式下替换:选中列后按c

保存到只读文件::w !sudo tee %

删除行尾空格:用替换实现,%s/\s\+$//g

同样的思路,删除空行或者只含有空格的行:%s/^\s\*$//g

匹配printf但不匹配定制的printf(此处为_printf):

/\(_\)\@<!printf

vim的正则表达与标准regex不一样,如需查看帮助:

:h /[

:h /zero-width

:h /\@

匹配类型转换,添加空格:int a = (int)b; -> int a = (int) b;

:%s/)\(&[a-zA-Z0-9]\)\@=/) /g

This entry was posted in tittle tattle. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *