delete everything from line a to line b
:a, b de
ex:
:1,10 de
Showing posts with label Vim. Show all posts
Showing posts with label Vim. Show all posts
Saturday, January 19, 2013
vim delete empty line (刪除空白行)
delete those lines which have no content :
:g/^$/d
delete those lines which are only composed of "space":
:g/^\s*$/d
delete those lines which are composed of "space or tab":
:g/^[ |\t]*$/d
刪除沒有內容的空行
:g/^$/d
:g/^$/d
刪除包含有空格組成的空行
:g/^\s*$/d
:g/^\s*$/d
除以空格或tab開頭到結尾的空行
:g/^[ |\t]*$/d
:g/^[ |\t]*$/d
From http://blog.cmchen.net/2006/12/25/325/
remove weird symbols in vim (刪除奇怪字元)
to remove character such as ^M, ^K,...
In vi, do a :%s/^M//g
To get the ^M hold the control key, press V then M (Both while holding the control key) and the ^M will appear. This will find all occurances and replace them with nothing.
vim 縮排
在 VIM 中撰寫程式,可以利用「gg」指令將游標移到視窗最上方、利用「v」切換到選取模式、再用「G」將游標移到檔案尾端 (即達到全選的功能),最後按「=」,VIM 便會幫你的程式做自動對齊
另外也可在選取後按
Shift+< : 將選取的程式碼往左縮排一次
Shift+> : 將選取的程式碼往右縮排一次
或是按一個數字後再按Shift+< , 就可做指定次數的縮排
Subscribe to:
Posts (Atom)