zaiste / vimified

Yet another Vim configuration
http://zaiste.github.com/vimified/
686 stars 130 forks source link

Trailing Whitespace #109

Closed tasmo closed 9 years ago

tasmo commented 9 years ago

I don't want to have removed my trailing whitespace automatically while saving. Sure I know many cases in which it is comfortable.

But for writing in Markdown (as an example) it is necessary to use two trailing blanks at a line to get a line break instead of using a paragraph.

I commented out the line for a quick solution but it should be swichable.

AdrienGiboire commented 9 years ago

@tasmo You can add this in your after.vimrc file:

fun! StripTrailingWhitespace()
    " Don't strip on these filetypes
    if &ft =~ 'markdown\|slim\|haml'
        return
    endif
    %s/\s\+$//e
endfun

autocmd! BufWritePre
autocmd BufWritePre * call StripTrailingWhitespace()
tasmo commented 9 years ago

That was quick. Many thanks!

AdrienGiboire commented 9 years ago

You're welcome :)