顯示具有 vim 標籤的文章。 顯示所有文章
顯示具有 vim 標籤的文章。 顯示所有文章

2014年1月9日 星期四

設定 Vim 縮排4 空白.

靈活使用上面的選項,就可以很好地調整縮進設置。
可以將下述設置加入到~/.vimrc中:
set sw=4
set ts=4

filetype indent on
autocmd FileType python setlocal et sta sw=4 sts=4

參考來源:
http://linux-wiki.cn/wiki/zh-tw/Vim%E4%BB%A3%E7%A0%81%E7%BC%A9%E8%BF%9B%E8%AE%BE%E7%BD%AE

2012年6月25日 星期一

[Linux] 解決 Vim 開啟dos檔案時出現 ^M

有時候常會在Vim 開啟檔案後碰到 ^M 這個字眼.
原因就是因為之前是dos 下編輯的檔案, 而vim 是用unix 開啟檔案, 所以他不認得dos的換行字元. 以下就是解決方式: 
 
Convert from dos/unix to unix
To convert the current file from any mixture of CRLF/LF-only line endings, so all lines end with LF only:
:e ++ff=dos Edit file again, using dos file format ('fileformats' is ignored).
:setlocal ff=unix This buffer will use LF-only line endings when written.
:w Write buffer using unix (LF-only) line endings.

來源: http://vim.wikia.com/wiki/File_format

清除字尾空白
:%s/\s\+$//
 
來源: http://vim.wikia.com/wiki/Remove_unwanted_spaces