1. Formatting
Ted implements a generalized, syntax independent auto-indentation,
based solely on curly brace matching.
Specifically, formatting is restricted to managing leading spaces in lines
based only upon the '{' and '}' braces at
the start and end of lines respectively. A line ending in an open brace increases
indent levels, and a line containing just closing braces decreases indent levels.
Two special cases are of note:
- A line where the first char is a hash "#" is never indented.
- And a line ending in a backslash when the next line starts with an open-brace indicates a block that is to be untouched.
This indent strategy is general enough to handle most well-formed
code and data for both Tcl and C.
2. Conventions
Ted presumes the use of a certain coding conventions regarding
the use of curley braces. These affect input when
Preferences/Indent-Auto is enabled.
2.1 Final opening brace should always be at EOL.
if {$i} {; # BAD
}
2.2 It's ok to start and terminate braces on same line.
if {$i} { set i 99; incr i }
2.3 Multiple open braces fine, as long as close does to.
if {$i} { while {$i} {
# This is ok.
}}
2.4 Multi-line statements don't indent until open-brace is seen.
if {$somevar > $othervar &&
$somevar > 0 } {
incr i
}
2.5 One exception: use of typed proc definition.
proc {i} { #TYPES: . int
}
3. Tabs
Ted does not normally use Tab characters: All indentation is performed with spaces.
The exception are with Makefiles, which require Tabs.
© 2008 Peter MacDonald