Re: [OT] CVS diff: hard vs. soft tabs

From: Derrick 'dman' Hudson (dman_at_dman13.dyndns.org)
Date: 10/10/03

  • Next message: Roberto Sanchez: "Re: fsck hangs my machine unpredictably"
    Date: Fri, 10 Oct 2003 12:33:17 -0400
    To: debian-user <debian-user@lists.debian.org>
    
    
    

    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
    :retab!

    | 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 :
        expandtab (et)
        shiftwidth (sw)
        softtabstop (sts)
        tabstop (ts)
    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).

    -D

    -- 
    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 debian-user-request@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    


  • Next message: Roberto Sanchez: "Re: fsck hangs my machine unpredictably"

    Relevant Pages

    • Re: Request for comment on my tiny learning project: dfighterdb (mytree)
      ... -In most of your code I looked at, your closing braces line up with ... -Your code uses tabs for indentation. ... The cast is unnecessary. ... I don't do the indentation myself. ...
      (comp.lang.c)
    • Re: Tabs vs. Spaces
      ... > everyone who reads my code has to suffer from my indentation style. ... code and view it on a viewer with 2-space tabs). ... programmers in general hate tabs. ...
      (alt.comp.lang.learn.c-cpp)
    • Re: do we really need everyone to become a programmer?
      ... about tabs vs. non-tabs or how many spaces you indent with. ... I use tabs for indentation and spaces for alignment. ... Formatting is only a small part of elegance, but there is certainly a strong correlation between poor formatting and inelegance. ... Some functions used degrees C (read the temperature), others used raw register values. ...
      (comp.dsp)
    • Re: Coding Style: indenting with tabs vs. spaces
      ... While I respect you opinion about tabs, I find tab indentation the most ... Tabs become "logical indentation". ... isn't forced on anotherone's editor. ... any patches to the Linux kernel will have tabs used correctly. ...
      (Linux-Kernel)
    • Re: Using TABs vs. spaces II. (the Philosophy flamewar reloaded ;-))
      ... I read somewhere that good-style Ruby code is indented by 2 spaces. ... code if the indentation is only at 2 spaces. ... spaces or just tabs rather than switching between the two. ... You can alter tab length in your editor (for at least most editors, ...
      (comp.lang.ruby)