2015-10-11 14 views

回答

1

你可以嘗試把這樣的事情在你的.vimrc:

autocmd CursorMoved,CursorMovedI * call CS() 

function CS() 
    if col(".") > 1 
     set cursorcolumn 
    else 
     set nocursorcolumn 
    endif 
endfunction 

更多信息,請閱讀

:h autocmd 
:h CursorMoved 
:h col() 
:h cursorcolumn 

編輯:在幫助CursorMoved有書面

小心:這很經常觸發,不要 做用戶不期望的任何事情或 ,這是緩慢的。

所以我希望這是一個更好一點(=更快)版本

function CS() 
    if &cuc == 0 && col(".") != 1 
     set cuc 
    elseif &cuc == 1 && col(".") == 1 
     set nocuc 
    endif 
endfunction 

之前的功能設置任何東西,它會檢查是否使用CursorColumn(&cuc)設置或不(嘗試:echo &cuc看值)。所以它只會在光標位置發生所需變化時進行設置,而不是每次光標移動。

:h expr-option

相關問題