dex man page



dex [-c command] [-t tag] [-r rcfile] [-V] [file]...


A small and flexible text editor.

Command Line Options

-c command

Run this command after reading the rc file and opening any files specified on command line.

-r rcfile

Read this rc file instead of ~/.dex/rc or /usr/share/dex/rc.

-t tag

Go to tag. Requires tags file generated by Exuberant Ctags.


Don't read the rc file.


Display the version number and exit.

Basic Usage

Here's some of the default key bindings. M-x means meta-x or alt-x and ^V is ctrl-v. See /usr/share/dex/bindings/default for more keys.

select lines
copy current line or selection
cut current line or selection
enter command line
search next
search previous
activate Nth tab

On the command line you can use tab to complete commands and most of their parameters. Run next or prev to switch to next or previous file. The commands open, save and quit should be obvious.


alias <name> <command>

Create an alias to command.

alias read "pass-through cat"

Now you can run "read file.txt" to insert file.txt to current file.

bind <key> [command]

Bind a key to command. If command is not given then binding for the key is removed.

insert delete home end pgup pgdown left right up down F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 enter tab space (or sp)

ctrl: C-X or ^X

meta/alt: M-X

shift: S-left

Key chains are supported. For example "^X c" (press ^X and then c). Keys are separated by spaces.


Move to beginning of file.


Move to beginning of line.

case [-lu]

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

-l lower case

-u upper case

cd <directory>

Change directory. Updates $PWD and $OLDPWD. "cd -" changes to previous directory ($OLDPWD).


Center view to cursor.


Clear current line.

close [-fqw]

Close file.

-f close file even if it hasn't been saved after last modification

-q quit if closing the last open file

-w close parent window if closing its last contained file

command [text]

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

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

Run external command and collect error messages. This can be used to run make and grep.

-1 read error messages from stdout instead of stderr

-p display "Press any key to continue" prompt

-s silent. both stderr and stdout are redirected to /dev/null

See also errorfmt and msg commands.


Copy current line or selection.


Cut current line or selection.


Delete character or selection.


Delete to end of line.

delete-word [-s]

Delete word after cursor.

-s be more "aggressive"


Move cursor down.


Move cursor to end of file.


Move cursor to end of line.


Erase character before cursor.


Erase to beginning of line.

erase-word [-s]

Erase word before cursor.

-s be more "aggressive"

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

-i ignore this error

See compile and msg commands for more information.

filter <command> [parameter]...

Filter selected text or whole file through external command.

Example: filter sort -r

format-paragraph [width]

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

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

ft <filetype> <extension>...

Add extensions for filetype.

ft -c <filetype> <regexp>...

Detect filetype by matching the regexp against first line of file.

ft -f <filetype> <regexp>...

Detect filetype by matching the regexp against filename.

ft -i <filetype> <interpreter>...

Connect interpreters to file type. Interpreter is parsed from the #! line in many scripts.


Interactive file opener. Lists all files in GIT repository.

Same keys work as in command mode, but with these changes:

Move up in file list.
Move down in file list.
Open file.
Open file but don't close git-open.
Go to end of file list.
Go to top of file list.

hi <name> [fg-color [bg-color]] [attribute]...

Set highlight color.

keep (-2) default (-1) black (0) red green yellow blue magenta cyan gray darkgray lightred lightgreen lightyellow lightblue lightmagenta lightcyan white

Color can be given as a numeric value too (-2..255).

Colors 16-255 are supported by modern xterm compatible terminal emulators. There's a 6x6x6 color cube at indexes 16..231. For these colors it is easiest to use the R/G/B syntax where R, G and B are values between 0 and 5.

Indexes 232..255 contain 24 grayscale values which can be used to specify grayscale value more accurately than using the R/G/B syntax.

bold lowintensity italic underline 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 color and attribute you need to specify both fg-color and bg-color if you want to set the "keep" attribute.

If you omit any color it is set to default (-1).

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.

include <filename>

Read commands from file.

insert [-km] <text>

Insert text.

-k insert one character at a time as if it has been typed

-m move after inserted text


Insert special character.

Insert control character, type decimal value of byte to insert or press o to insert octal byte value, x to insert hexadecimal byte value or u to insert hexadecimal unicode value.


Join selection or next line to current.


Move left.

line <number>

Go to line.

load-syntax <filename|filetype>

If argument contains / it is considered a filename.

move-tab <position|left|right>

Move current tab to numeric position, left or right.

msg [-np]

Show latest, next (-n) or previous (-p) message. If its location is known (compile error or tag message) then the file will be opened and cursor moved to the location.

-n next message

-p previous message

See also compile and tag commands.


Insert empty line under current line.


Display next file.

open [-e encoding] [file]...

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

-e encoding
Set file encoding. See "iconv -l" for list of supported encodings.

option <filetype> <option> <value>...

Add automatic options for a filetype. Options are automatically set when file is opened.

option [-r] <regexp> <option> <value>...

Add automatic options for filenames matching regexp.

pass-through [-ms] <command> [parameter]...

Run command and insert its output.

-m move after the inserted text

-s strip newline from end of the command output




Move cursor page down. See also scroll-pgdown.


Move cursor page up. See also scroll-pgup.


Display previous file.

quit [-f]


-f force quitting even if there are unsaved files

redo [choice]

Redo given or latest undid change. If there are multiple possibilities an informative 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.

repeat <count> <command> [parameters]...

Run command multiple times.

replace [-bcgi] <pattern> <replacement>

-b use basic instead of extended regular expression syntax

-c display confirmation before each replace

-g replace all matching text from a line

-i ignore case


Move right.

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

Run external command.

-p display "Press any key to continue" prompt

-s silent. both stderr and stdout are redirected to /dev/null

save [-dfu] [-e encoding] [filename]

Save file. By default line-endings (LF vs CRLF) are preserved.

-d save with DOS/CRLF line-endings

-f force saving read-only file

-u save with Unix/LF line-endings

-e encoding
Set file encoding. See "iconv -l" for list of supported encodings.


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


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


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


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

search [-Hnprw] [pattern]

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

-H don't add search pattern to history (meaningful only with the search pattern given as argument)

-n search next

-p search previous

-r start searching backwards

-w search word under cursor

select [-bl]

Start selecting.

-b select code block starting from { and ending to }

-l select whole lines

set [-gl] <option1> [value1] ...

Set option value. 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
Global value is just a default local value for opened files and never used for anything else. Changing global value does not affect any already opened files.

By default set changes both global and local values.

-g change only global option value

-l change only local option value of current file

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

To change option for specific filetypes and filenames use the option command.

setenv <name> <value>

Set environment variable.

shift <count>

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


Suspend program. Usually bound to ^Z.

tag [-r] [tag]

Save current location to stack and go to the location of tag. Requires tags file generated by Exuberant Ctags. If no tag is given then word under cursor is used as a tag instead.

-r return back

Tag files are searched from current working directory and its parent directories.

See also msg command.

toggle [-gv] <option> [value...]

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

-g toggle global option instead of local

-v display new value

If option has both local and global value then local is toggled unless -g is given.


Undo latest change.




Move cursor up.

view <N|last>

Display Nth or last open file.

wclose [-f]

Close window.

-f close even if there are unsaved files in the window


Change from vertical layout to horizontal and vice versa.


Next window.

word-bwd [-s]

Move cursor backward one word.

-s skip special characters

word-fwd [-s]

Move cursor forward one word.

-s skip special characters


Previous window.

wresize [-hv] [[+-]N]

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

-h resize horizontally

-v resize vertically

N Set size of current window to N characters.

+N Increase size of current window by N characters.

-N Decrease size of current window by N characters.

wsplit [-bhr] [file...]

Like open but at first splits current window vertically.

-b Add new window before current instead of after.

-h Split horizontally instead of vertically.

-r Split root instead of current window.


Swap positions of this and next frame.


Options can be changed using the set command. Enumerated option values can also be toggled. To see which options are enumerated type "toggle " on command line and press tab. You can also use the option command to set filetype/filename specific options.

Local and global options

Global values of these options serve as 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 file is opened. Set to "" to disable. Tab indentation is detected if the value is not "". Adjusts 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 line and column for each file to ~/.dex/file-history.

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 with of text. Used as default value for format-paragraph.

ws-error [special]

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

If expand-tab is true then same as tab-after-indent,tab-indent otherwise same as space-indent.

Display spaces used as alignment after tabs in indentation as error.

Display spaces in indentation as error. Note that this still allows using less than tab-width spaces at end of indentation for alignment.

Display tabs used anywhere else but indentation as errors.

Display 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).

Display trailing whitespace as error.

Local only options

brace-indent [false]

Scan for { and } 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 regular expression matches current line when enter is pressed and auto-indent is true then indentation is increased. Set to "" to disable.

Global only options

case-sensitive-search [true]

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

display-special [false]

Display special characters.

esc-timeout [100] 0...2000

When single escape is read from the terminal dex 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.

lock-files [true]

Lock files using ~/.dex/file-locks. Only protects from your own mistakes (two processes editing same file).

newline [unix]

Whether to use LF (unix) or CRLF (dos) line-endings. This is just a default value for new files.

scroll-margin [0]

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

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.

"*" if file is has been modified since last save.
"RO" if file is read-only.
Cursor row.
Total rows in file.
Cursor display column.
Cursor column as characters. If it differs from cursor display column it is show too (e.g. "2-9").
Position in percentage.
File encoding.
Miscellaneous status information.
Line-ending (LF or CRLF).
Add separator.
File type.
Hexadecimal unicode value value of character under cursor.
Literal %.

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

Format string for the right aligned part of status line.

tab-bar [horizontal]

Hide tab bar. horizontal
Show tab bar on top. vertical
Show tab bar on left if there's enough space, hide otherwise. auto
Show tab bar on left if there's enough space, on top otherwise.

tab-bar-max-components [0]

Maximum number of path components displayed in vertical tab bar. Set to 0 to disable.

tab-bar-width [25]

Width of vertical tab bar. Note that width of tab bar is automatically reduced to keep editing area at least 80 characters wide. Vertical tab bar is shown only if there's enough space.

Command Syntax

Command syntax is similar to shell but simpler.

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

Rc files can contain comments at beginning of line. Comment begins with # character and can be indented, but you can't put comment on same line with a command. This decision was made to make it possible to include # in commands without escaping.

Commands can contain environment variables. Variable always expands into a single argument even if it contains whitespace. Variables inside single or double quotes are NOT expanded. This makes it possible to bind a key to command which contains variable (inside single or double quotes) and the variable is 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 are always defined and override environment variables of same name.


Usually /usr/share/dex


Current file. Empty string if there's no filename.


Selected text or word under cursor. Empty string if there's no selection and cursor is not on a word.

Single quoted strings

Can't contain single quote, no escaping possible.

Double quoted strings

Horizontal tab
New line
Vertical tab
Form feed
Carriage return
Literal \
Hexadecimal byte value 0x0a. Note that 0x00 is not supported because strings are NUL-terminated.
Four hex digit unicode code point U+20AC.
Eight hex digit unicode code point U+20AC.

Command Line

In command line you can use up and down arrows to browse command history and tab to complete commands and most of their arguments.

Here's list of key bindings (totally obvious keys left out):

Go to beginning of command line.
Move left.
Leave command line.
Go to end of command line.
Move right.
Delete to end of command line.
Delete to beginning of command line.
Insert special character.
Erase word.

Search Mode

Search pattern is an extended regular expression.

Same keys work as in command mode, plus these additional keys:

Toggle case-sensitive-search option.
Reverse search direction.



You personal configuration.


Your personal syntax files. These override the syntax files which come with the program.


Records open files to protect you from accidentally editing file opened in another process. Used only if lock-files is true.

~/.dex/command-history and ~/.dex/search-history

Command and search history.


Last edited files and cursor positions.


Copy to ~/.dex/rc and customize.


Timo Hirvonen <tihirvon@gmail.com>

See Also


Referenced By


Explore man page connections for dex(1).