ked
ked
is a text editor. It is purpose-built for myself as a code editor
for use within a terminal multiplexer.
disclaimer
ked
is unsupported software and I advise against using it for real.
There are probably a lot of edgecases I have yet to find. You may
encounter bugs, which will cause ked
to crash, which will cause you to
lose your buffer modifications irrevocably. I may make minor
bug fixes, modifications, and improvements, but ked
will never be much
more than it is now. Presently it works well enough that after
bootstrapping the project with another editor, ked
itself has mostly
been with developed with ked
using macOS and GNU/Linux.
shortcuts
Presently the only way to change keyboard shortcuts is by editing the
code. As ked is built with Go without many dependencies, recompiling is
trivial.
The hardcoded keyboard shortcuts are the following:
Ctrl+X
exits the editor
Ctrl+C
cancel dialogs
Ctrl+W
saves the buffer
Ctrl+S
searches the buffer (use Ctrl+S
to jump through results)
Alt+Left
and Alt+Right
jump over wordish things
Ctrl+A
and Ctrl+E
move cursor to beginning and end of present
line
Ctrl+G
jumps to a specific line
PageUp
and PageDown
move, well, a single page up or down
Ctrl+K
deletes from cursor to the end of line; also deletes empty
lines
Alt+Backspace
deletes current word
Ctrl+_
undos recent actions
Tab
inserts one tab character to cursor position
Shift+Tab
(Backtab
) removes one level of tabulation from line
beginning
Alt+Up
and Alt+Down
jump to the previous or next empty line
Ctrl+P
displays the buffer selection dialog
Ctrl+F
displays the file-open dialog
Alt+F
closes the current buffer
Depending on your terminal settings, Alt
may be mapped to Esc
.
buffer management
We have a very minimalistic approach to buffer handling. You can open
new buffers, close them, save their contents to a file, and change
between them. A single buffer always occupies the available screen
space. I use it within tmux
, and if I need to see more than a single
buffer at a time, I will open several panes for that purpose.
Opening files into new buffers is based on the idea of first selecting a
root directory and then fuzzily finding filenames matching your filter.
By default, we ignore certain directories like .git
and
node_modules
. You may specify these exactly with the -ignoredirs
argument or ignoredir
option in the configuration file.
save hooks
Save hooks are command-lines, which are automatically executed after a
glob-matching buffer is saved to a file. To make the mechanism more
useful, all references to __ABSPATH__
in the command-line will be
replaced with the current buffer’s absolute path. If the command returns
successfully, ked
will reload the buffer’s contents from the file.
Note that the mechanism is fairly limited: We generate the savehook
command by splitting the command-line with spaces. The result is also
not shell-expanded. For more complex invocations, use a wrapper script
such as $HOME/bin/wrapper.sh __ABSPATH__
.
configuring with a file
ked
is mostly configured with a configuration file. See ked -h
for
the filepaths it looks from. Command-line argument -config
may also be
used to override the default filepaths.
An example configuration file is below. Note that we assume the relevant
programs used in save hooks are found via $PATH
.
tabsize=4
tabspaces=false
ignoredir=.git
ignoredir=node_modules
ignoredir=__pycache__
ignoredir=site-packages
maxfiles=50000
worddelims = " \t=&|,./(){}[]#+*%'-:?!'\""
warnfilesize=1048576
[filetype:*.c]
savehook=clang-format -i __ABSPATH__
tabsize=8
[filetype:*.go]
savehook=goimports -w __ABSPATH__
tabsize=4
tabspaces=true
highlight-keyword=bold:type
highlight-keyword=bold:func
highlight-keyword=bold:struct
highlight-keyword=bold:bold
highlight-keyword=underline:return
; highlight string literals
highlight-pattern=255:0:1:dim:"(\\.|[^"\\])*"
highlight-pattern=255:0:1:dim:'(\\.|[^'\\])*'
highlight-pattern=255:0:1:dim:`(\\.|[^`\\])*`
; highlight single-line comments
highlight-pattern=255:0:1:dim://.*
; highlight function calls
highlight-pattern=254:2:3:bold:([-_\w]+)\(
[filetype:*.md]
savehook=pandoc --atx-headers -f markdown -t gfm -o __ABSPATH__ __ABSPATH__
highlight-pattern=255:0:1:bold:#.+
highlight-pattern=255:0:1:dim:`(\\.|[^`\\])*`
[filetype:*.py]
savehook=black __ABSPATH__
highlight-keyword=bold:def
highlight-keyword=bold:class
highlight-pattern=255:0:1:dim:#.+
highlight-pattern=254:2:3:bold:([-_\w]+)\(
highlight-pattern=255:0:1:dim:"(\\.|[^"\\])*"
highlight-pattern=255:0:1:dim:'(\\.|[^'\\])*'
[filetype:Makefile*]
tabsize=8
tabspaces=false