jEdit makes a distinction between the tab width, which is is used when displaying hard tab characters, and the indent width, which is used when a level of indent is to be added or removed, for example by mode-specific auto indent routines. Both can be changed in one of several ways:
On a global or mode-specific basis in the the section called “The Editing Pane”.
pane of the the > dialog box. SeeIn the current buffer for the duration of the editing session in the the section called “The Buffer Options Dialog Box”.
> dialog box. SeeIn the current buffer for future editing sessions by
placing the following in one of the first or last 10 lines of
the buffer, where n
is the desired
tab width, and m
is the desired
indent width:
:tabSize=n
:indentSize=m
:
S+TAB
or
A+LEFT
) removes one level of indent from each selected
line, or the current line if there is no selection.
A+RIGHT
) adds one
level of indent to each selected line, or the current line if there is
no selection. Pressing Tab
while a multi-line selection
is active has the same effect.
C+e r
)
removes all whitespace from the end of each selected line, or the
current line if there is no selection.
Files containing hard tab characters may look less than ideal if the default tab size is changed, so some people prefer using multiple space characters instead of hard tabs to indent code.
This feature is known as soft tabs. Soft tabs can be enabled or disabled in one of several ways:
On a global or mode-specific basis in the the section called “The Editing Pane”.
pane of the > dialog box. SeeIn the current buffer for the duration of the editing session in the the section called “The Buffer Options Dialog Box”.
> dialog box. SeeIn the current buffer for future editing sessions by
placing the following in one of the first or last 10 lines
of the buffer, where flag
is
either “true” or “false”:
:noTabs=flag
:
Changing the soft tabs setting has no effect on existing tab characters; it only affects subsequently-inserted tabs.
> > converts soft tabs to hard tabs in the current selection, or the entire buffer if nothing is selected.
> > converts hard tabs to soft tabs in the current selection, or the entire buffer if nothing is selected.
The auto indent feature inserts the appropriate number of tabs or spaces at the beginning of a line by looking at program structure.
In the default configuration, pressing ENTER
will create a new line with the appropriate amount of indent
automatically, and pressing TAB
at the beginning
of, or inside the leading whitespace of a line will insert the
appropriate amount of indentation. Pressing it again will insert a
tab character.
The behavior of the ENTER
and
TAB
keys can be configured in the
pane of the
> dialog. box, just as with any other key. The
ENTER
key can be bound to one of the following, or
indeed any other command or macro:
.
, which is the default.
The TAB
can be bound to one of the following,
or again, any other command or macro:
.
, which is the default.
.
See the section called “The Shortcuts Pane” for details.
Auto indent behavior is mode-specific. In most edit modes, the indent of the previous line is simply copied over. However, in C-like languages (C, C++, Java, JavaScript), curly brackets and language statements are taken into account and indent is added and removed as necessary.
C+i
) indents
all selected lines, or the current line if there is no
selection.
To insert a literal tab or newline without performing
indentation, prefix the tab or newline with C+e v
.
For example, to create a new line without any indentation, type
C+e v ENTER
.