From cf5886795f80fcd091e497bce03cafb45008a9f6 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Tue, 11 Feb 2020 15:22:25 +0100 Subject: [PATCH] Useful :TrimWhitespace command to trim trailing spaces and such --- .vimrc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.vimrc b/.vimrc index 05acf1a..a5ca498 100644 --- a/.vimrc +++ b/.vimrc @@ -498,6 +498,14 @@ set listchars=tab:▸\ ,trail:· " Display whitespace set list +" Trim trailing whitespace with :TrimWhitespace +fun! TrimWhitespace() + let l:save = winsaveview() + keeppatterns %s/\s\+$//e + call winrestview(l:save) +endfun +command! TrimWhitespace call TrimWhitespace() + " enable words completion set dictionary+=/usr/share/dict/words " use ctrl-n ctrl-n instead of ctrl-x ctrl-k