Indentation in computer programs can be achieved in a variety of ways including using tabs or spaces, and with fancy features like auto-indent and tab emulation. Along with these possibilities, people have different opinions on the proper amount of indent for each line of a program. This page is intended to collect notes and resources to begin to understand the issues.
See
AboutThesePages.
Contents
Notes
- Doing a search of the nedit mailing list archives at http://www.nedit.org/community/mailing.shtml
on [indentation and tabs] will return quite a few hits which may be useful in understanding some of the issues. One particular post seemed helpful and was not in the archives on the day I tried to find it, so I've quoted it here.
Subject: Tabs and indentation
Date: Wed, 19 Jun 2002 14:10:06 -0500
From: "Heathcote, Tom" <Tom.Heathcote@bakeratlas.com>
Reply-To: discuss@nedit.org
To: "'discuss@nedit.org'" <discuss@nedit.org>
While we are talking of indenting...
when I first used NEdit I found the Tabs dialog rather confusing. I also find that other NEdit users in the office are sometimes confused by it, and don't always realize how to get tabs to work the way they want. I have spoken to a couple of people who thought they had set NEdit so it would never put tab characters in their source code, only to later discover that they had got it wrong and tabs had actually been entered.
It seems to me that most users will wish to have their indentation done in one of two ways :- with tabs only (and no spaces), or with spaces only (and no tabs). Both methods have their advantages and disadvantages, which I won't go into here.
Code which mixes tabs and spaces is problematic. The mixture has the disadvantages of both tab-based and space-based indentation, and the advantages of neither. Comments from others in this mailing list suggest that most people try to avoid mixing tabs and spaces.
Users of vi (and other editors without auto-indentation) often use a style that mixes tabs and spaces. But this seems to be because it is the quickest way to maintain indentation... the user "tabs across" to quickly get a large indent (usually with 8-space tabs) and then uses spaces to get indentation levels which fall between the tab stops. I am doubtful whether this is even necessary in NEdit., since auto indent makes the "tabbing across" unnecessary.
At present it is possible to choose NEdit options that mix spaces and tabs, but I don't think that the way it works is very useful:
Having both options switched off gives you a hard tab when the user presses the tab key, but spaces in the auto-indentation. This results in a truly bizarre effect, where you get a tab only at the point where the indentation increases:
....if x = 1
....>> doSomething
........doSomethingElse
........if y = 2
........>> doSomethingAgain
I find it hard to imagine that anyone actually uses this combination of settings.
Having both options switched on gives something a bit like the "vi" style... but not quite.
With NEdit you get something like this:
for i = 1 to n
....for j = 1 to m
....>> a[i,j] = 0
>> b[i,j] = 0
Whereas the usual "mixed" style would be:
for i = 1 to n
....for j = 1 to m
>> a[i,j] = 0
>> b[i,j] = 0
(where . represents a space, and ">> " represents a tab
This is similar, in a general sense, to the problem that Markus v. Brevern complained of -- two lines which are at the same indentation, have different whitespace sequences.
I have two different (and mutually exclusive) proposals for change:
Proposal 1 (the more radical one)
The two current options are not completely orthogonal, they are related closely enough that you would probably want to consider their combined effect. Is it really helpful to have two separate options?
I propose combining them into a single option which would simply switch between an all-tabs mode and an all-spaces mode. This would certainly be conceptually simpler, and (I think) probably corresponds to how most users would want to use NEdit.
Proposal 2 (the less radical one)
I think that one of the confusing aspects of the tabs dialog is the "mismatch" between the checkboxes. To achieve either spaces only or tabs only you need to set one option on, and the other option off.
I propose reversing the sense of ONE of the options. Specifically changing to "Don't use tab characters in padding and emulated tabs" or "Avoid tab characters in padding and emulated tabs".
I think this would make the dialog simpler, in that the two most common cases would be achieved by switching both options the same way (both off or both on).
It could be done without breaking existing macros by leaving the underlying setting the same, and just reversing the effect of the checkbox.
--
Tom Heathcote
<Currently, no significant content below this line.>
Resources
See
ResourceRecommendations. Feel free to add additional resources to these lists, but please follow the guidelines on
ResourceRecommendations including
ResourceRecommendations#Guidelines_for_Rating_Resources.
Recommended
Recommended for Specific Needs
Recommended by Others
No Recommendation
Not Recommended
Contributors
- () RandyKramer - 28 Jun 2002
- <If you edit this page: add your name here; move this to the next line; and include your comment marker (initials), if you have created one, in parenthesis before your WikiName.>
[[Main.RandyKramer#28 Jun 2002][]]
Page Ratings