mawww's experiment for a better code editor
= image:{logo}[K,32,32,link="{website}",title="Kakoune logo by p0nce"] Kakoune image:{cirrus-img}[link="{cirrus-url}"] image:{srht-img}[link="{srht-url}"] image:{irc-img}[link="{irc-url}"] ifdef::env-github,env-browser[:outfilesuffix: .asciidoc] :logo: http://kakoune.org/img/kakoune_logo_32.png :website: https://kakoune.org :cirrus-img: https://api.cirrus-ci.com/github/mawww/kakoune.svg :cirrus-url: https://cirrus-ci.com/github/mawww/kakoune :srht-img: https://builds.sr.ht/~mawww/kakoune.svg :srht-url: https://builds.sr.ht/~mawww/kakoune? :irc-img: https://img.shields.io/badge/IRC-%23kakoune-blue.svg :irc-url: https://web.libera.chat/?channels=kakoune :icons: font :toc: right :pp: ++
{website}
Modal editor -- Faster as in fewer keystrokes -- Multiple selections -- Orthogonal design
See https://github.com/mawww/golf for Kakoune solutions to vimgolf challenges, regularly beating the best Vim solution.
See the link:doc/design.asciidoc[design document] for more information on Kakoune's philosophy and design.
Kakoune is a code editor that implements Vi's "keystrokes as a text editing language" model. As it is also a modal editor, it is somewhat similar to the Vim editor (after which Kakoune was originally inspired).
Kakoune can operate in two modes: normal and insertion. In insertion mode, keys are directly inserted into the current buffer. In normal mode, keys are used to manipulate the current selection and to enter insertion mode.
Kakoune has a strong focus on interactivity. Most commands provide immediate and incremental results, while being competitive with Vim in terms of keystroke count.
Kakoune works on selections, which are oriented, inclusive ranges of characters. Selections have an anchor and a cursor. Most commands move both of them except when extending selections, where the anchor character stays fixed and the cursor moves around.
See https://vimeo.com/82711574
Join us on libera IRC #Kakoune
Features
* Multiple selections as a central way of interacting
* Powerful selection manipulation primitives
- Select all regex matches in current selections
- Keep selections containing/not containing a match for a given regex
- Split current selections with a regex
- Text objects (paragraph, sentence, nestable blocks)
* Powerful text manipulation primitives
- Align selections
- Rotate selection contents
- Case manipulation
- Indentation
- Piping each selection to external filter
* Client-Server architecture
- Multiple clients on the same editing session
- Use tmux, zellij, kitty, wezterm or your X11/Wayland window manager to
manage splits/panes by spawning clients connected to the same session
* Simple interaction with external programs
* Automatic contextual help
* Automatic as you type completion
* Macros
* Hooks
* Syntax Highlighting
- Supports multiple languages in the same buffer
- Highlight a buffer differently in different windows
Screenshots[[screenshot-i3]] .Kakoune in i3 image::doc/screenshot-i3.gif[Kakoune in i3]
[[screenshot-tmux]] .Kakoune in tmux image::doc/screenshot-tmux.gif[Kakoune in tmux]
Building
Kakoune's dependencies are:
* A {cpp}20 compliant compiler (GCC >= 10.3 or clang >= 11) along with its
associated {cpp} standard library (libstdc{pp} >= 10 or libc{pp})
To build, just type *make* in the root directory.
To generate man pages, type *make man* in the root directory.
Kakoune can be built on Linux, MacOS, and Cygwin. Due to Kakoune relying heavily
on being in a Unix-like environment, no native Windows version is planned.
InstallingIn order to install kak on your system, rather than running it directly from
its source directory, type make install. You can specify the PREFIX and
DESTDIR if needed.
====
====
====
====
====
====
====
Kakoune can be found in the https://software.opensuse.org/package/kakoune[repositories].
====
Kakoune can be found in the Ubuntu repositories.
If you want to compile from source on 20.04 or earlier, you must force the build to use GCC 10, which is not the default. Also, make sure you have .local/bin in your path so that kak is available after the installation.
====
Kakoune can be found in Debian 9 (Stretch) and later releases.
====
Kakoune is available in the official ports tree as https://www.freshports.org/editors/kakoune[editors/kakoune].
====
Building on OpenBSD 6.7 amd64.
Kakoune is available in the 6.7-current port tree as http://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/editors/kakoune/[editors/kakoune]
====
Kakoune is available in the Solus stable repository.
====
Kakoune is available in the repositories.
====
Kakoune is available in the repositories.
====
====
==== https://repology.org/project/kakoune/versions[image:https://repology.org/badge/vertical-allrepos/kakoune.svg[Packaging status]]
Running
Running *kak* launches a new kak session with a client on local terminal.
Run *kak -help* to discover the valid command line flags.
Configuration
^^^^^^^^^^^^^
There are two directories containing Kakoune's scripts:
* `runtime`: located in `../share/kak/` relative to the `kak` binary
contains the system scripts, installed with Kakoune.
* `userconf`: located in `$XDG_CONFIG_HOME/kak/`, which will fallback
to `$HOME/.config/kak/` if `$XDG_CONFIG_HOME` is not set, containing
the user configuration.
Unless `-n` is specified, Kakoune will load its startup script located
at `${runtime}/kakrc` relative to the `kak` binary. This startup script
is responsible for loading the user configuration.
First, Kakoune will search recursively for `.kak` files in the `autoload`
directory. It will first look for an `autoload` directory at
`${userconf}/autoload` and will fallback to `${runtime}/autoload` if
it does not exist.
Once all those files are loaded, Kakoune will try to source
`${runtime}/kakrc.local`, which is expected to contain distribution provided
configuration.
Finally, the user configuration will load from `${userconf}/kakrc`.
NOTE: If you create a user `autoload` directory in `${userconf}/autoload`,
the system one at `${runtime}/autoload` will not load anymore. You can
add a symbolic link to it (or to individual scripts) inside
`${userconf}/autoload` to keep loading system scripts.
Basic Interaction
-----------------
SelectionsThe main concept in Kakoune is the selection. A selection is an inclusive, directed range of characters. A selection has two ends, the anchor and the cursor.
There is always at least one selection, and a selection is always at least one character (in which case the anchor and cursor of the selection are on the same character).
Normal Mode
In normal mode, keys are not inserted directly inside the buffer, but are editing
commands. These commands provide ways to manipulate either the selections themselves
or the selected text.
Insert ModeWhen entering insert mode, keys are now directly inserted before each selection's cursor. Some additional keys are recognised in insert mode:
<esc>: leave insert mode
<backspace>: delete characters before cursors
<del>: delete characters under cursors
<left>, <right>, <up>, <down>: move cursors in given direction
<home>: move cursors to line beginning
<end>: move cursors to line ending
<c-n>: select next completion candidate
<c-p>: select previous completion candidate
<c-x>: explicit insert completion query, followed by:
f: explicit file completionw: explicit word completionl: explicit line completion<c-o>: disable automatic completion for this insert session
<c-r>: insert contents of the register given by next key
<c-v>: insert next keystroke directly into the buffer,
without interpreting it
<c-u>: commit changes up to now as a single undo group
<a-;>: escape to normal mode for a single command
Movement
See <<Appending>> below for instructions on extending (appending to) the current selection in order to select more text.
* `h`: select the character on the left of selection end
* `j`: select the character below th[REQUEST] autocompletion after N chars
[REQUEST] An Offical Kakoune `SKILL.md` for authoring and validation of `*.kak`
[BUG] Compile error: 'invalid use of ‘auto’'
[BUG] incorrect selection with zero-width characters in terminal.app
[BUG] `gd` and `gu` do not interact correctly with counts
[BUG] Performance deterioration in draft contexts with many cursors
[REQUEST] move cursor to start/end of line with wrap highlighter
Enabling mouse support and setting high `scrolloff` values causes an unequal amount of cursor movement per unit of mouse scroll movement.
JSON-RPC interaction with running client(s)
Scrollable info box?