forked from aminzai/vimrc
-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Thanks @aeglos for share this magic.
" Remove trailing whitespace when writing a buffer, but not for diff files.
" From: Vigil <[email protected]>
function RemoveTrailingWhitespace()
if &ft != "diff"
let b:curcol = col(".")
let b:curline = line(".")
silent! %s/\s\+$//
silent! %s/\(\s*\n\)\+\%$//
call cursor(b:curline, b:curcol)
endif
endfunction
"autocmd BufWritePre * call RemoveTrailingWhitespace()
map <localleader>r : call RemoveTrailingWhitespace()<cr>
" show trailing white spaces
highlight WhitespaceEOL ctermbg=red guibg=red
match WhitespaceEOL /\s\+$/
Metadata
Metadata
Assignees
Labels
No labels