carpal tunnel
Registered: 13/02/2002
Posts: 3212
Loc: Portland, OR
|
Quote:
Quote: tabstop should never be set to anything other than 8. You really should be using what vim calls 'softtabstop' (along with 'shiftwidth'), which allows you to edit as though a tabstop is 2 spaces, but leaves the tabstop definition at the standard 8 spaces.
I'm trying understand what you're saying here, but I don't get it (not a vim user if that matters).
I used the names of vim settings, since I believe Bitt mentioned using vi in another post, and it's the terminology I'm most familiar with.
A 'softtabstop' set to two spaces means that when you hit tab in the editor, rather than inserting a tab character, "\t", it will insert two spaces. Once you tab over a full tab stop, it replaces spaces with a tab character. This last behaviour is actually quite odious.
Fortunately, vim also has a setting called 'expandtab', which changes all literal tab characters into the equivalent number of spaces (depending, of course, on what your tabstop is).
Shiftwidth is a setting that allows you to shift lines of text (in- or outdent) by a certain number of spaces.
In vim, I never actually use the tab key. I use a shift operation to do all my non-automatic indenting.
Quote: Why would you want your tabs set to 8?
Using your favourite language, do the equivalent of the following: Code:
perl -e'print "\n\t#\n #\n";' There are 8 spaces in that last part. Run that wherever you choose and let me know how often those hash marks don't line up (assuming a fixed width font, of course). Next, create a simple text file containing those two lines. Print it out on paper, again with a fixed width font. I bet the colons line up, right? Then, in a shell, cat the file (I think the old DOS command was 'type'). How big are the tabs? Throw some <pre></pre> tags around it, and view it in a webpage. I bet those hash marks line up, right? They do in Firefox, links, lynx, and konqueror.
Aside from a text-editor where someone has manually changed the tabstop to something other than 8, a tabstop is 8 spaces. If you look at the documentation of the text-editor that person is using, I'd be willing to bet that the default tabstop (which they've changed) is 8.
Where else, other than your text editor, can you change how a tabstop is displayed? I'd bet nowhere. That's because 8 spaces is the standard. Don't change what's standard.
Quote: I usually indent everything 2 spaces and have my editor set to insert spaces instead of tabs.
This sounds like it's the equivalent of having 'expandtabs' turned on in vim.
Quote: Of course, with the editors I use (VS.net and Delphi) the whole tab functionality is really obsolete anyway. VS.net formats your code as soon as you put your closing brace and Delphi has a "smart tab" which inserts spaces up until you reach the next character-after-a-space on the previous line (or the most recent line that extends as far as you're typing).
Yes, smartindent is great -- vim has that, as well, and I use it. It doesn't make tab functionality obsolete, however, as, if there are literal tab characters in your file when it gets saved, then they're still there regardless of how your editor displays them.
Quote: However, on this subject, tabs in general just drive me nuts. In fact, if the editor doesn't have the option to insert spaces instead of tabs, I just ignore the tab button. I hate opening code in a different editor and having it look like garbage because the previous program used a different tab setting than the one I have now.
Now you know why you should never change the tabstop setting from 8. If you have, the only place your formatting will ever look "correct" is in the place it was originally edited.
Quote: And on THAT subject, why is it that no one seems to ever format SQL code?
We do -- it's a department coding standard. 
|