* Ben Giddings (ben / thingmagic.com) wrote:

> I completely agree.  It's just that when I'm reading code I don't want
> to change (say Ruby library code for example) it makes me uneasy to
> redo the buffer's indentation just to read it, then make sure not to
> save it.

In vi*, you have to explicitly tell it to save (:w); if you have unsaved
changes, it won't let you quit (:q) unless you really mean it (:q!).
You just need to avoid doing a :wq; if you do that, you better have set
up some sort of backup system.

Personally, I use:

  set backup
  set backupdir=~/.bak

Then I can always cp the backup from there if I screw up.  I don't do it
often enough to warrant anything more friendly.

Of course, the probability of screwing up when I just want to read a
file is much reduced when I use view/vim -R (readonly mode).

> It also comes up when I'm using a pager (less) rather than emacs.
> Changing its interpretation of tab characters isn't something I've
> ever wanted to try.

  setenv LESS '-x2'

> Anyhow, it is interesting to hear to arguments for using the tab
> character, but I'm going to stick with 2 spaces. :)

Whichever you use, I highly recommend setting your editor to display
whitespace where appropriate; it can be very useful in spotting bad
indentation, and can make it easier to see what's going on.

In vim:

  set listchars=tab:扔平,trail:平
  highlight NonText ctermfg=blue
  set list

Which gives you:

  module Foo
  遠毽毽毽class Bar
  遠毽毽毽遠毽毽毽def wibble
  扔平平平平平平平扔平平平平平平平扔平平平平平平平trailing_whitespace \平
  遠毽毽毽遠毽毽毽遠毽毽毽    :not_a_tab
  遠毽毽毽遠毽毽毽end
  遠毽毽毽end
  end

Coloured a nice dark blue (which complements my terminal backgrounds).

This should be mandatory for those users who mix tabs and spaces.  An
*awful* lot of code is like this, even in the Ruby core.  Scarily, it's
common in Python code too.

-- 
Thomas 'Freaky' Hurst  -  freaky / aagh.net  -  http://www.aagh.net/