Re: [OT] CVS diff: hard vs. soft tabs
From: Derrick 'dman' Hudson (dman_at_dman13.dyndns.org)
Date: Fri, 10 Oct 2003 12:33:17 -0400 To: debian-user <email@example.com>
On Fri, Oct 10, 2003 at 09:48:34AM -0400, Nori Heikkinen wrote:
| hey all,
| this is kind of off-topic, but i figured this is the community most
| likley to have dealt with this sort of thing in the past, and be
| opinionated about it.
| i've been editing a lot of code over the past few months that was
| originally saved to disk with hard tabs for indenting. i can't work
| with hard tabs, and so managed to reformat the entire thing to use
| spaces (basically a "s,^I, ," iirc) before i began my massive
| overhaul of this file.
Read ":help retab". It is so much nicer :-).
| now it's time to check it into CVS. i don't want every single line to
| show up as different just because of tab characters, so i need to find
| a good solution on how to transform my indents back into tab
| characters. clearly the reverse -- "s, ,^I," -- won't just work, as
| there are places where two spaces exist that i wouldn't want a tab.
:set noet sts=2 sw=2 ts=2
| is there some way to open the file in emacs (in which i assumer it was
| originally written; i use vim) and run it through a re-indentder with
| hard tabs on? or could i do this in vim?
You can do everything you need to in vim.
| suggestions & opinions welcome. thanks a lot,
I would either revert the source back to the original formatting and
commit that, or make a commit on just the format changes.
Key settings in vim you should familiarize yourself with are :
and also familiarize yourself with the "retab" command.
My style/rule/preference is:
tabs are always 8 spaces (ts=8) except for the moments you need to
change the setting so that :retab creates the proper
indentation levels (then revert back to ts=8)
use shiftwidth and softtabstop to control indentation levels.
I like a 4-space indentation, so I use sw=4 and sts=4.
never use tabs (:set et)
The retab command converts the indentation between tabs and spaces and
does so according to how et, sw, sts, and ts are set. The details are
in the manual (:help).
-- One man gives freely, yet gains even more; another withholds unduly, but comes to poverty. Proverbs 11:24 http://dman13.dyndns.org/~dman/
-- To UNSUBSCRIBE, email to firstname.lastname@example.org with a subject of "unsubscribe". Trouble? Contact email@example.com
- application/pgp-signature attachment: stored