dte text editor


dterc is the language used in dte configuration files (~/.dte/rc) and also in the command mode of the editor (Alt+x). The syntax of the language is quite similar to shell, but much simpler.

Commands are separated either by a newline or ; character. To make a command span multiple lines in an rc file, escape the newline (put \ at the end of the line).

Rc files can contain comments at the start of a line. Comments begin with a # character and can be indented, but they can't be put on the same line as a command.

Commands can contain environment variables. Variables always expand into a single argument even if they contain whitespace. Variables inside single or double quotes are NOT expanded. This makes it possible to bind keys to commands that contain variables (inside single or double quotes), which will be expanded just before the command is executed.


alias x "run chmod 755 $FILE"

$FILE is expanded when the alias x is executed. The command works even if $FILE contains whitespace.

Special variables

These variables are always defined and override environment variables of the same name.


The filename of the current buffer (or an empty string if unsaved).


The value of the filetype option for the current buffer.


The line number of the cursor in the current buffer.


The selected text or the word under the cursor.


The user configuration directory. This is either the value of $DTE_HOME when the editor first started, or the default value ($HOME/.dte).

Single quoted strings

Single quoted strings can't contain single quotes or escaped characters.

Double quoted strings

Double quoted strings may contain the following escapes:

\a, \b, \t, \n, \v, \f, \r
Control characters (same as in C)
Escape character
Double quote
Hexadecimal byte value 0x0a. Note that \x00 is not supported because strings are NUL-terminated.
Four hex digit Unicode code point U+20AC.
Eight hex digit Unicode code point U+20AC.


Configuration Commands

Configuration commands are used to customize certain aspects of the editor, for example adding key bindings, setting options, etc. These are the only commands allowed in user config files.

alias name command

Create an alias name for command. If no command is given then any existing alias for name is removed.

Aliases can be used in command mode or bound to keys, just as normal commands can. When aliases are used in place of commands, they are first recursively expanded (to allow aliases of aliases) and any additional arguments are then added to the end of the expanded command.

For example, if the following alias is created:

alias read 'pipe-from cat'

this can then be invoked as read file.txt, which will expand to the command pipe-from cat file.txt and thus cause file.txt to be inserted into the current buffer.

bind [-cns] key [command]

Bind command to key. If no command is given then any existing binding for key is removed.

Special keys:


C-X or ^X

The key is bound in normal mode by default, unless one or more of the following flags are used:

Add binding for command mode
Add binding for normal mode
Add binding for search mode

The commands available in normal mode are the ones listed in the main sections of this manual.

The commands avilable in command/search modes are as follows:

Most of these commands behave in a similar fashion to the normal mode commands of the same name. The exceptions should be self-explanatory.

See also:

set [-gl] option [value] ...

Set value for option. Value can be omitted for boolean option to set it true. Multiple options can be set at once but then value must be given for every option.

There are three kinds of options.

  1. Global options.

  2. Local options. These are file specific options. Each open file has its own copies of the option values.

  3. Options that have both global and local values. The Global value is just a default local value for opened files and is never used for anything else. Changing the global value does not affect any already opened files.

By default set changes both global and local values.

Change only global option value
Change only local option value of current file

In configuration files only global options can be set (no need to specify the -g flag).

See also: toggle and option commands.

setenv name [value]

Set (or unset) environment variable.

hi [-c] name [fg-color [bg-color]] [attribute]...

Set highlight color.

The name argument can be a token name defined by a dte-syntax file or one of the following, built-in highlight names:

The fg-color and bg-color arguments can be one of the following:

Colors 16 to 231 correspond to R/G/B colors. Colors 232 to 255 are grayscale values.

If the terminal has limited support for rendering colors, the fg-color and bg-color arguments will fall back to the nearest supported color (unless the -c flag is used).

The attribute argument(s) can be any combination of the following:

The color and attribute value keep is useful in selected text to keep fg-color and attributes and change only bg-color.

NOTE: Because keep is both a color and an attribute you need to specify both fg-color and bg-color if you want to set the keep attribute.

Unset fg/bg colors are inherited from highlight color default. If you don't set fg/bg for the highlight color default then terminal's default fg/bg is used.

Do nothing at all if the terminal can't display fg-color and/or bg-color with full precision

ft [-b|-c|-f|-i] filetype string...

Add a filetype association. Filetypes are used to determine which syntax highlighter and local options to use when opening files.

By default string is interpreted as one or more filename extensions.

Interpret string as a file basename
Interpret string as a regex pattern and match against the contents of the first line of the file
Interpret string as a regex pattern and match against the full (absolute) filename
Interpret string as a command interpreter name and match against the Unix shebang line (after removing any path prefix and/or version suffix)


ft c c h
ft -b make Makefile GNUmakefile
ft -c xml '<\?xml'
ft -f mail '/tmpmsg-.*\.txt$'
ft -i lua lua luajit

See also:

option [-r] filetype option value...

Add automatic option for filetype (as previously registered with the ft command). Automatic options are set when files are are opened.

Interpret filetype argument as a regex pattern instead of a filetype and match against full filenames

include [-bq] file

Read and execute commands from file.

Read built-in file instead of reading from the filesystem
Don't show an error message if file doesn't exist

Note: "built-in files" are config files bundled into the program binary. See the -B and -b flags in the dte man page for more information.

errorfmt [-i] compiler regexp [file|line|column|message|_]...

Register a regex pattern, for later use with the compile command.

When the compile command is invoked with a specific compiler name, the regexp pattern(s) previously registered with that name are used to parse messages from it's program output.

The regexp pattern should contain as many capture groups as there are extra arguments. These capture groups are used to parse the file, line, message, etc. from the output and, if possible, jump to the corresponding file position. To use parentheses in regexp but ignore the capture, use _ as the extra argument.

Running errorfmt multiple times with the same compiler name appends each regexp to a list. When running compile, the entries in the specified list are checked for a match in the same order they were added.

For a basic example of usage, see the output of dte -b compiler/go.

Ignore this error

load-syntax filename|filetype

Load a dte-syntax file into the editor. If the argument contains a / character it's considered a filename.

Note: this command only loads a syntax file ready for later use. To actually apply a syntax highlighter to the current buffer, use the set command to change the filetype of the buffer instead, e.g. set filetype html.

Editor Commands

quit [-f|-p] [exitcode]

Quit the editor.

The exit status of the process is set to exitcode, which can be in the range 0..125, or defaults to 0 if unspecified.

Force quit, even if there are unsaved files
Prompt for confirmation if there are unsaved files


Suspend the editor (run fg in the shell to resume).

cd directory

Change the working directory and update $PWD and $OLDPWD. Running cd - changes to the previous directory ($OLDPWD).

command [text]

Enter command mode. If text is given then it is written to the command line (see the default ^L key binding for why this is useful).

If no flags or just -r and no pattern given then dte changes to search mode where you can type a regular expression to search.

Don't add pattern to search history
Search next
Search previous
Start searching backwards
Search word under cursor


Trigger a full redraw of the screen.

Buffer Management Commands

open [-g|-t] [-e encoding] [filename]...

Open file. If filename is omitted, a new file is opened.

-e encoding
Set file encoding. See iconv -l for list of supported encodings.
Perform glob expansion on filename.
Mark buffer as "temporary" (always closeable, without warnings for "unsaved changes")

save [-fp] [-d|-u] [-b|-B] [-e encoding] [filename]

Save current buffer.

Write byte order mark (BOM)
Don't write byte order mark
Save with DOS/CRLF line-endings
Force saving read-only file
Save with Unix/LF line-endings
Open a command prompt if there's no specified or existing filename
-e encoding
Set file encoding. See iconv -l for list of supported encodings.

See also: newline and utf8-bom global options

close [-qw] [-f|-p]

Close file.

Force close file, even if it has unsaved changes
Prompt for confirmation if the file has unsaved changes
Quit if closing the last open file
Close parent window if closing its last contained file


Display next file.


Display previous file.

view N|last

Display Nth or last open file.

move-tab N|left|right

Move current tab to position N or 1 position left or right.

Window Management Commands

wsplit [-bhr] [-g|-n|-t] [filename]...

Split the current window.

filename arguments will be opened in a manner similar to the open command. If there are no arguments, the contents of the new window will be an additional view of the current buffer.

Add new window before current instead of after.
Perform glob expansion on filename.
Split horizontally instead of vertically.
Create a new, empty buffer.
Split root instead of current window.
Mark buffer as "temporary" (always closeable, without warnings for "unsaved changes")

wclose [-f|-p]

Close window.

Force close window, even if it contains unsaved files
Prompt for confirmation if there are unsaved files in the window


Next window.


Previous window.

wresize [-h|-v] [N|+N|-- -N]

If no parameter given, equalize window sizes in current frame.

Resize horizontally
Resize vertically
Set size of current window to N characters.
Increase size of current window by N characters.
Decrease size of current window by N characters. Use -- to prevent the minus symbol being parsed as an option flag, e.g. wresize -- -5.


Change from vertical layout to horizontal and vice versa.


Swap positions of this and next frame.

Movement Commands

Movement commands are used to move the cursor position.

Several of these commands also have -c and -l flags to allow creating character/line selections. These 2 flags are noted in the command summaries below, but are only described once, as follows:

Select characters
Select whole lines

left [-c]

Move one column left.

Move one column right.

up [-c|-l]

Move one line up.

down [-c|-l]

Move one line down.

pgup [-c|-l]

Move one page up.

pgdown [-c|-l]

Move one page down.

blkup [-c|-l]

Move one block up.

Note: a "block", in this context, is somewhat akin to a paragraph. Blocks are delimited by one or more blank lines

blkdown [-c|-l]

Move one block down.

word-fwd [-cs]

Move forward one word.

Skip special characters

word-bwd [-cs]

Move backward one word.

Skip special characters

bol [-cs]

Move to beginning of current line.

Move to beginning of indented text or beginning of line, depending on current cursor position.

eol [-c]

Move to end of current line.


Move to beginning of file.


Move to end of file.


Incrementally move to beginning of line, then beginning of screen, then beginning of file.


Incrementally move to end of line, then end of screen, then end of file.


Scroll view up one line. Keeps cursor position unchanged if possible.


Scroll view down one line. Keeps cursor position unchanged if possible.


Scroll one page up. Cursor position relative to top of screen is maintained. See also pgup.


Scroll one page down. Cursor position relative to top of screen is maintained. See also pgdown.


Center view to cursor.


Move to the bracket character paired with the one under the cursor. The character under the cursor should be one of {}[]()<>.

line number

Go to line.

tag [-r|tag]

Save the current file/cursor location to a stack and jump to the location of tag. If the tag argument is not given, the word under the cursor is used instead (unless -r is used).

The location for tag is determined by parsing a tags file from the current directory, or any of its parent directories. These files are expected be encoded in ctags format.

jump back to the previous location (and pop it off the stack)

See also: msg command.

msg [-n|-p|number]

Display and/or navigate messages, as generated by the compile and tag commands. If the activated message has an associated file location, the file will be opened and the cursor moved to the appropriate position.

If no -n or -p flag or number argument is given, the current message will be displayed.

Next message
Previous message

Editing Commands


Cut current line or selection.

copy [-k]

Copy current line or selection.

Keep selection (by default, selections are lost after copying)

paste [-c]

Paste text previously copied by the copy or cut commands.

Paste at the cursor position, even when the text was copied as a whole-line selection (where the usual default is to paste at the start of the next line)


Undo latest change.

redo [choice]

Redo changes done by the undo command. If there are multiple possibilities a message is displayed:

Redoing newest (2) of 2 possible changes.

If the change was not the one you wanted, just run undo and then, for example, redo 1.


Clear current line.


Join selection or next line to current.


Insert empty line under current line.


Delete character after cursor (or selection).


Delete character before cursor (or selection).

delete-eol [-n]

Delete to end of line.

Delete newline if cursor is at end of line


Erase to beginning of line.

delete-word [-s]

Delete word after cursor.

Be more "aggressive"

erase-word [-s]

Erase word before cursor.

Be more "aggressive"


Delete current line.

case [-l|-u]

Change text case. The default is to change lower case to upper case and vice versa.

Lower case
Upper case

insert [-k|-m] text

Insert text into the buffer.

Insert one character at a time, as if manually typed. Normally text is inserted exactly as specified, but this option allows it to be affected by special input handling like auto-indents, whitespace trimming, line-by-line undo, etc.
Move after inserted text

replace [-bcgi] pattern replacement

Replace all instances of text matching pattern with the replacement text.

The pattern argument is a POSIX extended regex.

The replacement argument is treated like a template and may contain several, special substitutions:

Note: extra care must be taken when using double quotes for the pattern argument, since double quoted arguments have their own (higher precedence) backslash sequences.

Use basic instead of extended regex syntax
Ask for confirmation before each replacement
Replace all matches for each line (instead of just the first)
Ignore case


replace 'Hello World' '& (Hallo Welt)'
replace "[ \t]+$" ''
replace -cg '([^ ]+) +([^ ]+)' '\2 \1'

shift count

Shift current or selected lines by count indentation levels. Count is usually -1 (decrease indent) or 1 (increase indent).

To specify a negative number, it's necessary to first disable option parsing with --, e.g. shift -- -1.

wrap-paragraph [width]

Format the current selection or paragraph under the cursor. If paragraph width is not given then the text-width option is used.

This command merges the selection into one paragraph. To format multiple paragraphs use the external fmt program with the filter command, e.g. filter fmt -w 60.

select [-bkl]

Enter selection mode. All movement commands while in this mode extend the selected area.

Note: A better way to create selections is to hold the Shift key whilst moving the cursor. The select command exists mostly as a fallback, for terminals with limited key binding support.

Select block between opening { and closing } curly braces
Keep existing selections
Select whole lines


Cancel selection.

External Commands

filter [-l] command [parameter]...

Filter selected text or whole file through external command.


filter sort -r

Note that command is executed directly using execvp. To use shell features like pipes or redirection, use a shell interpreter as the command. For example:

filter sh -c 'tr a-z A-Z | sed s/foo/bar/'
Operate on current line instead of whole file, if there's no selection

pipe-from [-ms] command [parameter]...

Run external command and insert its standard output.

Move after the inserted text
Strip newline from end of output

pipe-to [-l] command [parameter]...

Run external command and pipe the selected text (or whole file) to its standard input.

Can be used to e.g. write text to the system clipboard:

pipe-to xsel -b
Operate on current line instead of whole file, if there's no selection

run [-ps] command [parameters]...

Run external command.

Display "Press any key to continue" prompt
Silent -- both stderr and stdout are redirected to /dev/null

compile [-1ps] errorfmt command [parameters]...

Run external command and collect output messages. This can be used to run e.g. compilers, build systems, code search utilities, etc. and then jump to a file/line position for each message.

The errorfmt argument corresponds to a regex capture pattern previously specified by the errorfmt command. After command exits successfully, parsed messages can be navigated using the msg command.

Read error messages from stdout instead of stderr
Display "Press any key to continue" prompt
Silent. Both stderr and stdout are redirected to /dev/null

See also: errorfmt and msg commands.

eval command [parameter]...

Run external command and execute its standard output text as dterc commands.

exec-open [-s] command [parameter]...

Run external command and open all filenames listed on its standard output.

Don't yield terminal control to the child process

Example uses:

exec-open -s find . -type f -name *.h
exec-open -s git ls-files --modified
exec-open fzf -m --reverse

exec-tag [-s] command [parameter]...

Run external command and then execute the tag command with its first line of standard output as the argument.

Don't yield terminal control to the child process

Example uses:

exec-tag -s echo main
exec-tag sh -c 'readtags -l | cut -f1 | sort | uniq | fzf --reverse'

Other Commands

repeat count command [parameters]...

Run command count times.

toggle [-gv] option [values]...

Toggle option. If list of values is not given then the option must be either boolean or enum.

toggle global option instead of local
display new value

If option has both local and global values then local is toggled unless -g is used.

show [-c] type [key]

Display current values for various configurable types.

The type argument can be one of:

Show command aliases
Show key bindings
Show highlight colors
Show command history
Show environment variables
Show compiler error formats
Show filetype associations
Show built-in configs
Show last recorded macro
Show option values
Show search history
Show window dimensions

The key argument is the name of the entry to look up (e.g. the alias name). If this argument is omitted, the full list of entries of the specified type will be displayed in a new buffer.

write value to command line (if possible)

macro action

Record and replay command macros.

The action argument can be one of:

Begin recording
Stop recording
Toggle recording on/off
Stop recording, without overwriting the previous macro
Replay the previously recorded macro

Once a macro has been recorded, it can be viewed in text form by running show macro.


Options can be changed using the set command. Enumerated options can also be toggled. To see which options are enumerated, type "toggle " in command mode and press the tab key. You can also use the option command to set default options for specific file types.

Global options

Search is case-insensitive.
Search is case-sensitive.
If search string contains an uppercase letter search is case-sensitive, otherwise it is case-insensitive.

display-invisible [false]

Display invisible characters.

display-special [false]

Display special characters.

esc-timeout [100] 0...2000

When single escape is read from the terminal dte waits some time before treating the escape as a single keypress. The timeout value is in milliseconds.

Too long timeout makes escape key feel slow and too small timeout can cause escape sequences of for example arrow keys to be split and treated as multiple key presses.

filesize-limit [250]

Refuse to open any file with a size larger than this value (in mebibytes). Useful to prevent accidentally opening very large files, which can take a long time on some systems.

lock-files [true]

Keep a record of open files, so that a warning can be shown if the same file is accidentally opened in multiple dte processes.

See also: the FILES section in the dte man page.

newline [unix]

Whether to use LF (unix) or CRLF (dos) line-endings in newly created files.

Note: buffers opened from existing files will have their newline type detected automatically.

optimize-true-color [true]

If set to true, this option will cause the hi command to automatically replace 24-bit #RRGGBB colors with palette colors 16-255, but only if there's an exact color match among the default, extended palette colors.

This allows defining color schemes in #RRGGBB notation while still sending the shortest possible escape sequence to the terminal.

Note: this optimization only works if the terminal has not been configured with custom values for colors 16-255. If you have changed these extended palette colors, you should set this option to false.

select-cursor-char [true]

Whether to include the character under the cursor in selections.

scroll-margin [0]

Minimum number of lines to keep visible before and after cursor.

set-window-title [false]

Set the window title to the filename of the current buffer (if the terminal supports it).

show-line-numbers [false]

Show line numbers.

statusline-left [" %f%s%m%r%s%M"]

Format string for the left aligned part of status line.

Prints * if file is has been modified since last save.
Prints RO for read-only buffers or TMP for temporary buffers.
Cursor row.
Total rows in file.
Cursor display column.
Cursor column as characters. If it differs from cursor display column then both are shown (e.g. 2-9).
Position in percentage.
File encoding.
Miscellaneous status information.
Line-ending (LF or CRLF).
Line-ending (only if CRLF).
Separator (a single space, unless the preceding format character expanded to an empty string).
Like %s, but 3 spaces instead of 1.
File type.
Hexadecimal Unicode value value of character under cursor.
Literal %.

statusline-right [" %y,%X %u %E%s%b%s%n %t %p "]

Format string for the right aligned part of status line.

tab-bar [true]

Whether to show the tab-bar at the top of each window.

utf8-bom [false]

Whether to write a byte order mark (BOM) in newly created UTF-8 files.

Note: buffers opened from existing UTF-8 files will have their BOM (or lack thereof) preserved as it was, unless overridden by the save command.

Local options

brace-indent [false]

Scan for { and } characters when calculating indentation size. Depends on the auto-indent option.

filetype [none]

Type of file. Value must be previously registered using the ft command.

indent-regex [""]

If this regex pattern matches the current line when enter is pressed and auto-indent is true then indentation is increased. Set to "" to disable.

Local and global options

The global values for these options serve as the default values for local (per-file) options.

auto-indent [true]

Automatically insert indentation when pressing enter. Indentation is copied from previous non-empty line. If also the indent-regex local option is set then indentation is automatically increased if the regular expression matches current line.

detect-indent [""]

Comma-separated list of indent widths (1-8) to detect automatically when a file is opened. Set to "" to disable. Tab indentation is detected if the value is not "". Adjusts the following options if indentation style is detected: emulate-tab, expand-tab, indent-width.


set detect-indent 2,3,4,8

emulate-tab [false]

Make delete, erase and moving left and right inside indentation feel as if there were tabs instead of spaces.

expand-tab [false]

Convert tab to spaces on insert.

file-history [true]

Save and restore cursor positions for previously opened files.

See also: the FILES section in the dte man page.

indent-width [8]

Size of indentation in spaces.

syntax [true]

Use syntax highlighting.

tab-width [8]

Width of tab. Recommended value is 8. If you use other indentation size than 8 you should use spaces to indent.

text-width [72]

Preferred width of text. Used as the default argument for the wrap-paragraph command.

ws-error [special]

Comma-separated list of flags that describe which whitespace errors should be highlighted. Set to "" to disable.

If the expand-tab option is enabled then this is the same as tab-after-indent,tab-indent. Otherwise it's the same as space-indent.
Highlight spaces used for alignment after tab indents as errors.
Highlight space indents as errors. Note that this still allows using less than tab-width spaces at the end of indentation for alignment.
Highlight tabs used anywhere other than indentation as errors.
Highlight tabs in indentation as errors. If you set this you most likely want to set "tab-after-indent" too.
Display all characters that look like regular space as errors. One of these characters is no-break space (U+00A0), which is often accidentally typed (AltGr+space in some keyboard layouts).
Highlight trailing whitespace characters at the end of lines as errors.