You could set it to output spaces instead of a literal \t, but I don't like having to do 8x or 4x to remove a level of indentation (in vi) when I can use simple x instead.
Learn your vi. Assuming your cursor is on the code, and not on the indent, using the 'x' method to remove a tab takes you two key strokes: 0x, or ^X. But there's another way, that will work with spaces as well, doesn't require the cursor to be on the indentation, and which is sensitive to movement commands (so you can outdent regions): <<. And to indent: >>.
sub foo { <TAB>my ($bar, $baz) = @_; <TAB>if($bar) { <TAB><TAB>return $baz; <TAB>} <TAB>return 0; }
If I have tabstop set to 8 and someone else has it set to 4, it will look right in both cases.
Sure, in this simple example it will. But suppose you have your tabstop set to 8, write the above code, check it in to source control, and someone with a tabstop set to 4 checks it out, and modifies it as follows:
sub foo { <TAB>my ($bar, $baz) = @_; <TAB>if($bar) { <TAB><TAB>if (fuzzle ()) { <TAB><TAB><TAB># Expression taking 60 characters. <TAB><TAB>} <TAB><TAB>return $baz; <TAB>} <TAB>return 0; }
Looks great, with an 8 character margin on the right to spare, so it fits in the pleasing "72 character" width, and certainly it fits in the default 80 character window.

The code is checked in, and you check it out again. You look at the code in your 80 character window, and the last four characters of the new code will appear wrapped to the next line. Yuck!

If even becomes much yuckier if the coding guideline says "4 character indent", and some people use an 8 character tab-stop, and some use a 4 character tab-stop. Say the current block has <TAB> as indentation and two if/else statements are added, by different programmers. One will use <TAB><TAB> as indentation - the other <TAB><SP><SP><SP><SP>. Fun! Fun! Fun!

Abigail


In reply to Re: <blocThe classical <TAB> issue by Abigail-II
in thread The classical TAB issue by Lorand

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.