News for hackers. Stuff that matters.
Re:Ask HN: What's in your .vimrc file? by meese_ on Thursday October 01, 2009 @11:22PM (#856374)
Here's a function I wrote to get rid of trailing white space:

    fun! s:RemoveWhitespace()
    	if &bin | return | endif
    	if search('\s\+$', 'n')
    		let line = line('.')
    		let col = col('.')
    		sil %s/\s\+$//ge
    		call cursor(line, col)
    		echo 'Removed trailing whitespace.'
    	else
    		echo 'No trailing whitespace found.'
    	endif
    endf
You can map it with:

    nn <silent> ,R :cal<SID>RemoveWhitespace()<cr>

There are no comments on this comment yet.