2017-07-16 77 views
3

enter image description here入門vim的

由於我的.vimrc擺脫塊的人物一樣,在一行的末尾,我如何才能在VIM行末擺脫這些褐色的人物?

回答

5

這可能是以前搜索$(行尾), 或顯式顯示行結束標記的結果。

您可以使用:set nohlsearch禁用突出顯示的搜索結果。

您可以使用:set nolist禁用行標記的顯式結束。

+1

:設置nohlsearch有竅門。謝謝 – abc

3

如果你真的要刪除的尾隨空白:

:%s/[[:space:]]\+$// 
1

我有我的~/.vimrc文件的功能,我使用我的節省routine`

fun! CleanExtraSpaces() 
     let save_cursor = getpos(".") 
     let old_query = getreg('/') 
     :%s/\s\+$//e 
     call setpos('.', save_cursor) 
     call setreg('/', old_query) 
endfun 
com! Cls :call CleanExtraSpaces() 

" auto clean trailing spaces 
if has("autocmd") 
    autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh :call CleanExtraSpaces() 
endif 

此代碼擺脫鏈接在保存期間所有exta空間中,或者您可以通過鍵入 手動調用它:Cls<Enter>

最重要的部分是:%s/\s\+$//e

\s\+ .............. one space or mor 
$ ................. at the end of the line 
e ................. if not exists any extra space it ignores error messages