added a more simple function for removing trailing white spaces on save
This commit is contained in:
parent
1115f7492a
commit
7aa8367204
1 changed files with 9 additions and 11 deletions
|
|
@ -263,19 +263,17 @@ function! s:show_documentation()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" function to remove trailing white spaces from document, simply type
|
" Removes trailing spaces
|
||||||
" :StripTrailingWhitespace when in Normal mode
|
function TrimWhiteSpace()
|
||||||
command! -nargs=? -range=% -complete=custom,s:StripTrailingWhitespace
|
%s/\s*$//
|
||||||
\ StripTrailingWhitespace <line1>,<line2>call s:StripTrailingWhitespace(<f-args>)
|
''
|
||||||
|
|
||||||
function! s:StripTrailingWhitespace(...) abort
|
|
||||||
let confirm = a:0
|
|
||||||
execute a:firstline . ',' . a:lastline . 's/\s\+$//e' . (confirm ? 'c' : '')
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:StripCompletionOptions(A,L,P) abort
|
"Removes trailing spaces on save
|
||||||
return "-confirm"
|
autocmd FileWritePre * call TrimWhiteSpace()
|
||||||
endfunction
|
autocmd FileAppendPre * call TrimWhiteSpace()
|
||||||
|
autocmd FilterWritePre * call TrimWhiteSpace()
|
||||||
|
autocmd BufWritePre * call TrimWhiteSpace()
|
||||||
|
|
||||||
" Highlight symbol under cursor on CursorHold
|
" Highlight symbol under cursor on CursorHold
|
||||||
autocmd CursorHold * silent call CocActionAsync('highlight')
|
autocmd CursorHold * silent call CocActionAsync('highlight')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue