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

Reply via email to