Tab or No Tab :: C++ Compilers
Hi,
I program using Visual C++, vi, some occassionally using KDevelop. I usually experience problems with tabs and spaces. I use tab (3 spaces) in Visual C++. However, vi almost always open the source files with random spaces.
In general, do developers use spaces instead of tabs?
Thanks,
Kuphryn
It has been my experience that most programers are unaware that tabs and spaces are DIFFERENT FRIGGIN'' CHARACTERS and also unaware that tabs can be displayed with DIFFERENT FRIGGIN'' SIZES.
I''m maticulous when aligning code to ensure that it looks correctly no matter what the tab size is. A few ''auto-type''/''auto-tab'' features of MSVC6 are broken in this regard, where they insert tabs where you really need spaces.
Like this code:
MSVC6 will use tabs to fill inthe blank space by default. Perhaps vi/emacs/kDev all have this "feature".
There should be one, and exactly one, tab at the _start_ of each line, and then spaces to line up the call. Seems really trivial to me, and seems to be ignored by everyone else (who''s code I''ve looked at).
I''m maticulous when aligning code to ensure that it looks correctly no matter what the tab size is. A few ''auto-type''/''auto-tab'' features of MSVC6 are broken in this regard, where they insert tabs where you really need spaces.
Like this code:
functioncall(with, a, pile, of, parameters);
MSVC6 will use tabs to fill inthe blank space by default. Perhaps vi/emacs/kDev all have this "feature".
There should be one, and exactly one, tab at the _start_ of each line, and then spaces to line up the call. Seems really trivial to me, and seems to be ignored by everyone else (who''s code I''ve looked at).
quote:Original post by Magmai Kai Holmlor
There should be one, and exactly one, tab at the _start_ of each line, and then spaces to line up the call. Seems really trivial to me, and seems to be ignored by everyone else (who''s code I''ve looked at).
Never knew/heard that. I''ll take it into consideration henceforth.
I wanna work for Microsoft!
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
quote:Original post by Magmai Kai Holmlor
There should be one, and exactly one, tab at the _start_ of each line, and then spaces to line up the call. Seems really trivial to me, and seems to be ignored by everyone else (who''s code I''ve looked at).
You''re not the only one who''s worried about things like that. I indent in the same manner: so that no matter the size of the tabs everything is aligned correctly.
This problem can be easily fixed in MSVC...
Tools->Options->Tabs... Set auto-indent to "Default", tab-size and indent-size to the same thing (I use 4) and choose "insert spaces".
MSVC is pretty smart about handling this. When you press TAB, it''ll move to the next TAB location (in my example, a multiple of 4). If you hit then hit BACKSPACE, it''ll back-up through one space at a time. But, in a situation where MSVC has inserted a TAB for you, for example when you hit RETURN at the end of a line and it continues at the same indent (true for SMART and DEFAULT auto-indent), but then hit BACKSPACE, it will skip back a whole TAB''s worth. Definitely useful when you''re closing off a brace and what scoot back at the end of a block.
And now, when you load up the file in any editor the spacing will be the same, because there are no TAB characters (unless those characters were already in the file before you specified the above options). I believe MSVC will convert TABS to SPACES when you enable the above options and then resave the file, but I may be wrong...
Tools->Options->Tabs... Set auto-indent to "Default", tab-size and indent-size to the same thing (I use 4) and choose "insert spaces".
MSVC is pretty smart about handling this. When you press TAB, it''ll move to the next TAB location (in my example, a multiple of 4). If you hit then hit BACKSPACE, it''ll back-up through one space at a time. But, in a situation where MSVC has inserted a TAB for you, for example when you hit RETURN at the end of a line and it continues at the same indent (true for SMART and DEFAULT auto-indent), but then hit BACKSPACE, it will skip back a whole TAB''s worth. Definitely useful when you''re closing off a brace and what scoot back at the end of a block.
And now, when you load up the file in any editor the spacing will be the same, because there are no TAB characters (unless those characters were already in the file before you specified the above options). I believe MSVC will convert TABS to SPACES when you enable the above options and then resave the file, but I may be wrong...
I agree with the usual action: only use tabs to line up the "depth level of the code". It''s usefull for loops indeed. However, would it not also be acceptable to include a comment at the beginning of your main.cpp, stating the tab-number you used...?
I agree w/ Simagery. Always use spaces. Set up your editor so that it inserts spaces when you hit the Tab key. Then there is no issue.
The only text files that should have tab characters in them are ones that require them (like makefiles).
The only text files that should have tab characters in them are ones that require them (like makefiles).
Tabs are evil and the tool of the devil. Try to edit a file that''s been around for 10 years and editted by different people with tabs set to 2, 3, 4, and/or 8 and you''ll agree.
The size savings for using tabs is worthlessly trivial and there''s no point in having two rules (tab, then spaces) when one will do (only spaces).
-Mike
The size savings for using tabs is worthlessly trivial and there''s no point in having two rules (tab, then spaces) when one will do (only spaces).
-Mike
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement