Strip trailing whitespace

1 Point

Ory Band Ory Band

4 years ago

Define a command to strip trailing whitespace to all end of lines.

function! StripTrailingWhitespaces()
    let l = line(".")
    let c = col(".")
    %s/\s\+$//e
    call cursor(l, c)
endfunction

" You can of course rename the command however you wish.
command! StripTrailingWhitespaces call StripTrailingWhitespaces()