jEdit makes a distinction between the tab width, which is is used when displaying 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 smart indent routines. Both can be changed in one of several ways:
On a global or mode-specific basis in Editing and Mode-Specific panes of the the Utilities>Global Options dialog box.
In the current buffer for the duration of the editing session in the Utilities>Buffer Options dialog box; see the section called "The Buffer Options Dialog Box".
In 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: |
Edit>Source Code>Shift Indent Left (shortcut: Shift-Tab or Alt-Left) adds one level of indent to each selected line, or the current line if there is no selection.
Edit>Source Code>Shift Indent Right (shortcut: Alt-Right) removes one level of indent from 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.
Because files indented using tab characters may look less than ideal when viewed on a system with a different default tab size, it is sometimes desirable to use multiple spaces, known as soft tabs, instead of real tab characters, to indent code.
Soft tabs can be enabled or disabled in one of several ways:
On a global or edit mode-specific basis in the Editing and Mode-Specific panes of the Utilities>Global Options dialog box.
In the current buffer for the duration of the editing session in the Utilities>Buffer Options dialog box; see the section called "The Buffer Options Dialog Box".
In 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.
Edit>Source>Spaces to Tabs converts soft tabs to hard tabs in the current selection, or the entire buffer if nothing is selected.
Edit>Source>Tabs to Spaces 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.
If indent on enter is enabled, pressing Enter will create a new line with the appropriate amount of indent automatically. If indent on tab is enabled, 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.
By default, both indent on enter and indent on tab is enabled. This can be changed in one of several ways:
On a global or mode-specific basis in the Editing and Mode-Specific panes of the Utilities>Global Options dialog box.
In the current buffer for the duration of the editing session in the Utilities>Buffer Options dialog box; see the section called "The Buffer Options Dialog Box".
In the current buffer for future editing sessions by placing the following in the first or last 10 lines of a buffer, where flag is either "true" or "false":
:indentOnEnter=flag:indentOnTab=flag: |
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.
Edit>Source Code>Indent Selected Lines (shortcut: Control-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 Control-E V. For example, to create a new line without any indentation, type Control-E V Enter.