[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Revert only whitespace changes

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Wed, 15 Jun 2011 02:16:25 +0300

Daniel Shahaf wrote on Wed, Jun 15, 2011 at 02:07:00 +0300:
> > Bonus points for a tool which keeps real indentation changes, and only
> > discards tab<->space conversions which do not change the indentation
> > level. :-)
>
> vim -c 'source /dev/mind-reader' -c 'wq'
>
> Not all OS's provide the necessary device file, though.

Okay, more seriously, here's a Vim script...

The first two lines are the configuration, you shouldn't have to change
anything below them.

:set tabstop=8 shiftwidth=8
:set expandtab

:g/^/call MaybeRetab()
func! MaybeRetab()
  normal! ^
  let before = virtcol('.')
  .retab
  let after = virtcol('.')
  if before != after
    undo
  endif
endfunction
Received on 2011-06-15 01:17:03 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.