LinuxCommandLibrary

kak

kak

TLDR

Open a file and enter normal mode, to execute commands

$ kak [path/to/file]
copy


Enter insert mode from normal mode, to write text into the file
$ i
copy


Escape insert mode, to go back to normal mode
$ <Escape>
copy


Replace all instances of "foo" in the current file with "bar"
$ %s[foo]<Enter>c[bar]<Escape>
copy


Unselect all secondary selections, and keep only the main one
$ <Space>
copy


Search for numbers and select the first two
$ /\d+<Enter>N
copy


Insert the contents of a file
$ !cat [path/to/file]<Enter>
copy


Save the current file
$ :w<Enter>
copy

SYNOPSIS

kak -help

kak -version

kak -l

kak -clear

kak -f keys [-q] [-i] file...

kak -p session_id

kak -s session_id -d [-n] [-ro] [-E command] [+line[:column]|+:] file...

kak [-c session_id|-s session_id] [-n] [-ro] [-ui ui_type] [-e command] [-E command] [+line[:column]|+:] file...

DESCRIPTION

Kakoune is a code editor heavily inspired by Vim, as such most of its commands are similar to Vi's ones, and it shares Vi's "keystrokes as a text editing language" model.

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 still being competitive (as in keystroke count) with Vim.

Kakoune works on selections, which are oriented, inclusive range of characters, selections have an anchor and a cursor character. Most commands move both of them, except when extending selection where the anchor character stays fixed and the cursor one moves around.

For more information, use the :doc command after starting Kakoune, the Kakoune wiki at https://github.com/mawww/kakoune/wiki or the main Kakoune web site: https://kakoune.org/

OPTIONS

-help

display a help message and quit

-version

display kakoune version and quit

-n

do not load resource files on startup (kakrc, autoload, rc etc)

-l

list existing sessions

-d

run as a headless session (requires -s)

-e command

execute command after the client initialization phase

-E command

execute command after the server initialization phase

-f keys

enter in filter mode: select the whole file, then execute keys

-i suffix

backup the files on which a filter is applied using the given suffix

-q

when in filter mode, don't print any errors

-p session_id

send the commands written on the standard input to session session_id

-c session_id

connect to the given session

-s session_id

set the current session name to session_id

-ui type

select the user interface, can be one of ncurses, dummy or json

-clear

remove sessions that terminated in an incorrect state (e.g. after a crash)

-ro

enter in readonly mode, all the buffers opened will not be written to disk

+line[:column]

specify a target line and column for the first file; when the plus sign is followed by only a colon, then the cursor is sent to the last line of the file

file

one or more files to edit

ENVIRONMENT

KAKOUNE_POSIX_SHELL

Overrides the posix shell binary path to use for %sh{...} expansion.

KAKOUNE_CONFIG_DIR

Overrides the location of the directory containing kakoune user configuration, defaults to $XDG_CONFIG_HOME/kak if unset.

XDG_CONFIG_HOME

Path to the user configuration directory, defaults to $HOME/.config/kak if unset.

XDG_RUNTIME_DIR

Path to the user session sockets, defaults to $TMPDIR/kakoune if unset.

FILES

In the paths documented below, <rtdir> refers to the runtime directory, whose value is determined in relation to the path to the kak binary: <rtdir> = <path_to_kak_binary>/../share/kak.

If not started with the -n switch, Kakoune will first load <rtdir>/kakrc, which will in turn load the following additional files:

if the $KAKOUNE_CONFIG_DIR/kak/autoload directory exists, recursively load every
*.kak files in it and its sub-directories
if it does not exist, fall back to the system-wide autoload directory
in <rtdir>/autoload, and recursively load all files in a similar way
<rtdir>/kakrc.local, if it exists; this is a user-defined system-wide
configuration
$KAKOUNE_CONFIG_DIR/kak/kakrc, if it exists; this is the user configuration

Consequently, if the $KAKOUNE_CONFIG_DIR/kak/autoload directory exists, only scripts stored within that directory will be loaded - the built-in *.kak files will not be.

Users who still want to have the built-in scripts loaded along their own can create a symbolic link to <rtdir>/autoload (or to individual scripts in it) in their user-configuration directory:

ln -s <rtdir>/autoload "${XDG_CONFIG_HOME:-$HOME/.config}"/kak/autoload

EXAMPLES

Edit a file:

kak /path/to/file

Edit multiple files (multiple buffers will be created):

kak ./file1.txt /path/to/file2.c

Insert a modeline that sets the tabstop variable at the beginning of several source code files:

kak -f "ggO// kak: tabstop=8<esc>" *.c

SEE ALSO

vi(1), vim(1), sam(1plan9)

Copied to clipboard