vim: trim trailing spaces

This commit is contained in:
2026-03-09 10:13:23 +01:00
parent 13ee868d5d
commit 234e29f367

View File

@@ -45,6 +45,17 @@ let g:netrw_winsize = 25
call matchadd('colorcolumn', '\%101v', 100) call matchadd('colorcolumn', '\%101v', 100)
highlight colorcolumn ctermbg=red highlight colorcolumn ctermbg=red
fun! TrimWhitespace()
" Skip if the filetype is markdown
if &ft =~ 'markdown'
return
endif
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfun
autocmd BufWritePre * call TrimWhitespace()
" undofile - This allows you to use undos after exiting and restarting " undofile - This allows you to use undos after exiting and restarting
" This, like swap and backups, uses .vim-undo first, then ~/.vim/undo " This, like swap and backups, uses .vim-undo first, then ~/.vim/undo
" :help undo-persistence " :help undo-persistence