2 ms·
If you wrap it in a function it wont clobber the last search pattern, and use winsaveview()/winrestview() to not move the cursor/view around. fun! TrimWhites
by arp242 3y ago
If you wrap it in a function it wont clobber the last search pattern, and use winsaveview()/winrestview() to not move the cursor/view around.
fun! TrimWhitespace()
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfun
command! TrimWhitespace call TrimWhitespace()
Little bit more, but not too much and gives a much nicer experience IMHO.
- Zardoz84 3y agooh, nice improvement!