DTERC(5) | File Formats Manual | DTERC(5) |
NAME¶
dterc - Command and configuration language used by dte(1)
SYNOPSIS¶
Commands:
Configuration Commands:
alias name command
bind key [command]
set [-gl] option [value] ...
setenv name [value]
hi [-c] name [fg-color [bg-color]]
[attribute]...
ft [-b|-c|-f|-i] filetype
string...
option [-r] filetype option value...
include [-bq] file
errorfmt [-i] compiler regexp
[file|line|column|message|_]...
load-syntax filename|filetype
Editor Commands:
quit [-f|-p] [exitcode]
suspend
cd directory
command [text]
search [-Hnprw] [pattern]
refresh
Buffer Management Commands:
open [-g|-t] [-e encoding]
[filename]...
save [-fp] [-d|-u] [-b|-B]
[-e encoding] [filename]
close [-qw] [-f|-p]
next
prev
view N|last
move-tab N|left|right
Window Management Commands:
wsplit [-bghnrt] [filename]...
wclose [-f|-p]
wnext
wprev
wresize [-h|-v] [N|+N|-- -N]
wflip
wswap
Movement Commands:
left [-c]
right [-c]
up [-c|-l]
down [-c|-l]
pgup [-c|-l]
pgdown [-c|-l]
blkup [-c|-l]
blkdown [-c|-l]
word-fwd [-cs]
word-bwd [-cs]
bol [-cs]
eol [-c]
bof
eof
bolsf
eolsf
scroll-up
scroll-down
scroll-pgup
scroll-pgdown
center-view
match-bracket
line number
tag [-r] [tag]
msg [-n|-p]
Editing Commands:
cut
copy [-k]
paste [-c]
undo
redo [choice]
clear
join
new-line
delete
erase
delete-eol [-n]
erase-bol
delete-word [-s]
erase-word [-s]
delete-line
case [-l|-u]
insert [-km] text
replace [-bcgi] pattern replacement
shift count
wrap-paragraph [width]
select [-bkl]
unselect
External Commands:
filter [-l] command [parameter]...
pipe-from [-ms] command [parameter]...
pipe-to [-l] command [parameter]...
run [-ps] command [parameters]...
compile [-1ps] errorfmt command
[parameters]...
eval command [parameter]...
exec-open [-s] command [parameter]...
exec-tag [-s] command [parameter]...
Other Commands:
repeat count command [parameters]...
toggle [-gv] option [values]...
show [-c] type [key]
macro action
Options:
Global options:
case-sensitive-search [true]
display-invisible [false]
display-special [false]
esc-timeout [100] 0...2000
filesize-limit [250]
lock-files [true]
newline [unix]
select-cursor-char [true]
scroll-margin [0]
set-window-title [false]
show-line-numbers [false]
statusline-left [" %f%s%m%r%s%M"]
statusline-right [" %y,%X %u %E%s%b%s%n %t %p "]
tab-bar [true]
utf8-bom [false]
Local options:
brace-indent [false]
filetype [none]
indent-regex [""]
Local and global options:
auto-indent [true]
detect-indent [""]
emulate-tab [false]
expand-tab [false]
file-history [true]
indent-width [8]
syntax [true]
tab-width [8]
text-width [72]
ws-error [special]
DESCRIPTION¶
dterc is the language used in dte(1) 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.
Example:
-
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.
$FILE
$FILETYPE
$LINENO
$WORD
$DTE_HOME
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)
- \e
- Escape character
- \\
- Backslash
- \"
- Double quote
- \x0a
- Hexadecimal byte value 0x0a. Note that \x00 is not supported because strings are NUL-terminated.
- \u20ac
- Four hex digit Unicode code point U+20AC.
- \U000020ac
- Eight hex digit Unicode code point U+20AC.
COMMANDS¶
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
Example:
-
alias read 'pipe-from cat'
Now you can run read file.txt to insert file.txt into the current buffer.
bind key [command]
Special keys:
• left
• right
• up
• down
• insert
• delete
• home
• end
• pgup
• pgdown
• begin (keypad "5" with Num Lock off)
• enter
• tab
• space
• F1..F12
Modifiers:
set [-gl] option [value] ...
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.
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]
hi [-c] name [fg-color [bg-color]] [attribute]...
The name argument can be a token name defined by a dte-syntax(5) file or one of the following, built-in highlight names:
• default
• nontext
• noline
• wserror
• selection
• currentline
• linenumber
• statusline
• commandline
• errormsg
• infomsg
• tabbar
• activetab
• inactivetab
• dialog
The fg-color and bg-color arguments can be one of the following:
• No value (equivalent to default)
• A numeric value between -2 and 255
• A 256-color palette value in R/G/B notation (e.g. 0/3/5)
• A true color value in CSS-style #RRGGBB notation (e.g.
#ab90df)
• keep (-2)
• default (-1)
• black (0)
• red (1)
• green (2)
• yellow (3)
• blue (4)
• magenta (5)
• cyan (6)
• gray (7)
• darkgray (8)
• lightred (9)
• lightgreen (10)
• lightyellow (11)
• lightblue (12)
• lightmagenta (13)
• lightcyan (14)
• white (15)
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:
• bold
• dim
• italic
• underline
• strikethrough
• blink
• reverse
• invisible
• keep
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.
- -c
- 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...
By default string is interpreted as one or more filename extensions.
- -b
- Interpret string as a file basename
- -c
- Interpret string as a regex(7) pattern and match against the contents of the first line of the file
- -f
- Interpret string as a regex(7) pattern and match against the full (absolute) filename
- -i
- Interpret string as a command interpreter name and match against the Unix shebang line (after removing any path prefix and/or version suffix)
Examples:
-
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:
• The option command (below)
• The filetype option (below)
• The dte-syntax(5) man page
option [-r] filetype option value...
include [-bq] file
- -b
- Read built-in file instead of reading from the filesystem
- -q
- 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(1) man page for more information.
errorfmt [-i] compiler regexp [file|line|column|message|_]...
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.
- -i
- Ignore this error
load-syntax filename|filetype
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]
The exit status of the process is set to exitcode, which can be in the range 0..125, or defaults to 0 if unspecified.
suspend
cd directory
command [text]
search [-Hnprw] [pattern]
refresh
Buffer Management Commands¶
open [-g|-t] [-e encoding] [filename]...
- -e encoding
- Set file encoding. See iconv -l for list of supported encodings.
- -g
- Perform glob(7) expansion on filename.
- -t
- Mark buffer as "temporary" (always closeable, without warnings for "unsaved changes")
save [-fp] [-d|-u] [-b|-B] [-e encoding] [filename]
- -b
- Write byte order mark (BOM)
- -B
- Don't write byte order mark
- -d
- Save with DOS/CRLF line-endings
- -f
- Force saving read-only file
- -u
- Save with Unix/LF line-endings
- -p
- 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]
next
prev
view N|last
move-tab N|left|right
Window Management Commands¶
wsplit [-bghnrt] [filename]...
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.
wclose [-f|-p]
wnext
wprev
wresize [-h|-v] [N|+N|-- -N]
wflip
wswap
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:
left [-c]
right [-c]
up [-c|-l]
down [-c|-l]
pgup [-c|-l]
pgdown [-c|-l]
blkup [-c|-l]
Note: a "block", in this context, is somewhat akin to a paragraph. Blocks are delimited by one or more blank lines
blkdown [-c|-l]
word-fwd [-cs]
- -s
- Skip special characters
word-bwd [-cs]
- -s
- Skip special characters
bol [-cs]
- -s
- Move to beginning of indented text or beginning of line, depending on current cursor position.
eol [-c]
bof
eof
bolsf
eolsf
scroll-up
scroll-down
scroll-pgup
scroll-pgdown
center-view
match-bracket
line number
tag [-r] [tag]
This command requires a tags file generated by ctags(1). tags files are searched for in the current working directory and its parent directories.
- -r
- jump back to the previous location
See also: msg command.
msg [-n|-p]
Editing Commands¶
cut
copy [-k]
- -k
- Keep selection (by default, selections are lost after copying)
paste [-c]
- -c
- 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
redo [choice]
-
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
join
new-line
delete
erase
delete-eol [-n]
- -n
- Delete newline if cursor is at end of line
erase-bol
delete-word [-s]
- -s
- Be more "aggressive"
erase-word [-s]
- -s
- Be more "aggressive"
delete-line
case [-l|-u]
insert [-km] text
replace [-bcgi] pattern replacement
The pattern argument is a POSIX extended regex(7).
The replacement argument is treated like a template and may contain several, special substitutions:
• Backslash sequences \1 through \9 are
replaced by sub-strings that were "captured" (via parentheses) in
the pattern.
• The special character & is replaced by the full string
that was matched by pattern.
• Literal \ and & characters can be inserted in
replacement by escaping them (as \\ and \&).
• All other characters in replacement represent themselves.
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.
- -b
- Use basic instead of extended regex syntax
- -c
- Ask for confirmation before each replacement
- -g
- Replace all matches for each line (instead of just the first)
- -i
- Ignore case
Examples:
-
replace 'Hello World' '& (Hallo Welt)' replace "[ \t]+$" '' replace -cg '([^ ]+) +([^ ]+)' '\2 \1'
shift count
To specify a negative number, it's necessary to first disable option parsing with --, e.g. shift -- -1.
wrap-paragraph [width]
This command merges the selection into one paragraph. To format multiple paragraphs use the external fmt(1) program with the filter command, e.g. filter fmt -w 60.
select [-bkl]
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.
unselect
External Commands¶
filter [-l] command [parameter]...
Example:
-
filter sort -r
Note that command is executed directly using execvp(3). 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/'
- -l
- Operate on current line instead of whole file, if there's no selection
pipe-from [-ms] command [parameter]...
pipe-to [-l] command [parameter]...
Can be used to e.g. write text to the system clipboard:
-
pipe-to xsel -b
- -l
- Operate on current line instead of whole file, if there's no selection
run [-ps] command [parameters]...
compile [-1ps] errorfmt command [parameters]...
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.
- -1
- Read error messages from stdout instead of stderr
- -p
- Display "Press any key to continue" prompt
- -s
- Silent. Both stderr(3) and stdout(3) are redirected to /dev/null
See also: errorfmt and msg commands.
eval command [parameter]...
exec-open [-s] command [parameter]...
- -s
- 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]...
- -s
- 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]...
toggle [-gv] option [values]...
If option has both local and global values then local is toggled unless -g is used.
show [-c] type [key]
The type argument can be one of:
- alias
- Show command aliases
- bind
- Show key bindings
- color
- Show highlight colors
- command
- Show command history
- env
- Show environment variables
- errorfmt
- Show compiler error formats
- ft
- Show filetype associations
- include
- Show built-in configs
- macro
- Show last recorded macro
- option
- Show option values
- search
- Show search history
- wsplit
- 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.
- -c
- write value to command line (if possible)
macro action
The action argument can be one of:
- record
- Begin recording
- stop
- Stop recording
- toggle
- Toggle recording on/off
- cancel
- Stop recording, without overwriting the previous macro
- play
- Replay the previously recorded macro
Once a macro has been recorded, it can be viewed in text form by running show macro.
OPTIONS¶
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¶
case-sensitive-search [true]
display-invisible [false]
display-special [false]
esc-timeout [100] 0...2000
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]
lock-files [true]
See also: the FILES section in the dte(1) man page.
newline [unix]
Note: buffers opened from existing files will have their newline type detected automatically.
select-cursor-char [true]
scroll-margin [0]
set-window-title [false]
show-line-numbers [false]
statusline-left [" %f%s%m%r%s%M"]
- %f
- Filename.
- %m
- Prints * if file is has been modified since last save.
- %r
- Prints RO for read-only buffers or TMP for temporary buffers.
- %y
- Cursor row.
- %Y
- Total rows in file.
- %x
- Cursor display column.
- %X
- Cursor column as characters. If it differs from cursor display column then both are shown (e.g. 2-9).
- %p
- Position in percentage.
- %E
- File encoding.
- %M
- Miscellaneous status information.
- %n
- Line-ending (LF or CRLF).
- %N
- Line-ending (only if CRLF).
- %s
- Separator (a single space, unless the preceding format character expanded to an empty string).
- %S
- Like %s, but 3 spaces instead of 1.
- %t
- File type.
- %u
- Hexadecimal Unicode value value of character under cursor.
- %%
- Literal %.
statusline-right [" %y,%X %u %E%s%b%s%n %t %p "]
tab-bar [true]
utf8-bom [false]
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]
filetype [none]
indent-regex [""]
Local and global options¶
The global values for these options serve as the default values for local (per-file) options.
auto-indent [true]
detect-indent [""]
Example:
-
set detect-indent 2,3,4,8
emulate-tab [false]
expand-tab [false]
file-history [true]
See also: the FILES section in the dte(1) man page.
indent-width [8]
syntax [true]
tab-width [8]
text-width [72]
ws-error [special]
- auto-indent
- 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.
- space-align
- Highlight spaces used for alignment after tab indents as errors.
- space-indent
- Highlight space indents as errors. Note that this still allows using less than tab-width spaces at the end of indentation for alignment.
- tab-after-indent
- Highlight tabs used anywhere other than indentation as errors.
- tab-indent
- Highlight tabs in indentation as errors. If you set this you most likely want to set "tab-after-indent" too.
- special
- 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).
- trailing
- Highlight trailing whitespace characters at the end of lines as errors.
SEE ALSO¶
AUTHORS¶
Craig Barnes
Timo Hirvonen
March 2021 |