Elastic tabstop
Encyclopedia
In text editor
applications in computing
, elastic tabstops are an alternative way to handle tabstops, with a primary focus on editing source code
in computer programming
. The idea was first proposed by Nick Gravgaard as a solution for programmers who argue about what kind of indentation
is best; tab or space character
s. Joel Spolsky
wrote a short note giving publicity to this idea.
Elastic tabstops differ from traditional fixed tabstops because columns in lines above and below the "cell" that is being changed are always kept aligned. As the width of text before a tab character changes, the tabstops on adjacent lines are also changed to fit the widest piece of text in that column.
This method has some strengths over the older methods of code indentation, as it saves time for the programmer when he or she arranges the code and allows for proportional fonts in addition to the fixed-width fonts. On the other hand, this approach can make the code look unorganized on editors that do not have support for it, and it requires an indentation style which is interpreted correctly by this feature.
If the programmer, for example, changes the function name "volume_cylinder" to "volume" and constant name "PI" to "MATH_CONSTANT_PI", the code automatically realigns:
Text editor
A text editor is a type of program used for editing plain text files.Text editors are often provided with operating systems or software development packages, and can be used to change configuration files and programming language source code....
applications in computing
Computing
Computing is usually defined as the activity of using and improving computer hardware and software. It is the computer-specific part of information technology...
, elastic tabstops are an alternative way to handle tabstops, with a primary focus on editing source code
Source code
In computer science, source code is text written using the format and syntax of the programming language that it is being written in. Such a language is specially designed to facilitate the work of computer programmers, who specify the actions to be performed by a computer mostly by writing source...
in computer programming
Computer programming
Computer programming is the process of designing, writing, testing, debugging, and maintaining the source code of computer programs. This source code is written in one or more programming languages. The purpose of programming is to create a program that performs specific operations or exhibits a...
. The idea was first proposed by Nick Gravgaard as a solution for programmers who argue about what kind of indentation
Indentation
An indentation may refer to:* A notch, or deep recesses; for instance in a coastline, or a carving in rock* The placement of text farther to the right to separate it from surrounding text....
is best; tab or space character
Character (computing)
In computer and machine-based telecommunications terminology, a character is a unit of information that roughly corresponds to a grapheme, grapheme-like unit, or symbol, such as in an alphabet or syllabary in the written form of a natural language....
s. Joel Spolsky
Joel Spolsky
Avram Joel Spolsky is a software engineer and writer. He is the author of Joel on Software, a blog on software development. He was a Program Manager on the Microsoft Excel team between 1991 and 1994. He later founded Fog Creek Software in 2000 and launched the Joel on Software blog...
wrote a short note giving publicity to this idea.
Elastic tabstops differ from traditional fixed tabstops because columns in lines above and below the "cell" that is being changed are always kept aligned. As the width of text before a tab character changes, the tabstops on adjacent lines are also changed to fit the widest piece of text in that column.
This method has some strengths over the older methods of code indentation, as it saves time for the programmer when he or she arranges the code and allows for proportional fonts in addition to the fixed-width fonts. On the other hand, this approach can make the code look unorganized on editors that do not have support for it, and it requires an indentation style which is interpreted correctly by this feature.
Example
The following C program demonstrates how related code can be aligned using elastic tabstops, even when using a proportional font. The coloured backgrounds show the tabstop grouping.
/* This blank line prevents the red and yellow tabstops from combining */
|
If the programmer, for example, changes the function name "volume_cylinder" to "volume" and constant name "PI" to "MATH_CONSTANT_PI", the code automatically realigns:
/* This blank line prevents the red and yellow tabstops from combining */
|
Implementations
Current implementations of elastic tabstops:- GeditGeditgedit is a text editor for the GNOME desktop environment, Mac OS X and Microsoft Windows. Designed as a general purpose text editor, gedit emphasizes simplicity and ease of use...
(requires Nick Gravgaard's plugin) - Code BrowserCode browserA code Browser is an editor, sometimes with folding or other advanced layout capabilities, designed to structure source code or, by extension, other kinds of text file...
- Inform 7
- Google's Go programming languageGo (programming language)Go is a compiled, garbage-collected, concurrent programming language developed by Google Inc.The initial design of Go was started in September 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. Go was officially announced in November 2009. In May 2010, Rob Pike publicly stated that Go was being...
in the tabwriter package
See also
- IndentationIndentationAn indentation may refer to:* A notch, or deep recesses; for instance in a coastline, or a carving in rock* The placement of text farther to the right to separate it from surrounding text....
for the task - Indentation style for the various styles
- Programming styleProgramming styleProgramming style is a set of rules or guidelines used when writing the source code for a computer program. It is often claimed that following a particular programming style will help programmers to read and understand source code conforming to the style, and help to avoid introducing errors.A...
- Tab keyTab keyTab key on a keyboard is used to advance the cursor to the next tab stop.- Origin :The word tab derives from the word tabulate, which means "to arrange data in a tabular, or table, form"...
for the keyboard key and the ASCII character - Tab stopTab stopA tab stop on a typewriter is a location where the carriage movement is halted by mechanical gears. Tab stops are set manually, and pressing the tab key causes the carriage to go to the next tab stop...
for the general concept
External links
- Nick Gravgaard's article Elastic tabstops - the solution to the tabs-versus-spaces issue
- Slashdot article on the subject
- Joel Spolsky's publicity link
- Jamie Zawinski's article Tabs versus Spaces: An Eternal Holy War.
- Go programming language "tabwriter" package.