LinuxCommandLibrary

kak

Edit text files interactively

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
$ <Esc>
copy

Replace all instances of "foo" in the current file with "bar"
$ %s[foo]<Enter>c[bar]<Esc>
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 [options] [file...]
kak -c session [file...]
kak -s session [file...]

PARAMETERS

-c session
    Connect to an existing editing session by its ID. If no files are specified, it connects to the default client of that session.

-s session
    Start a new editing session with the specified ID. If files are provided, they are opened in this new session.

-e command
    Execute a Kakoune command string after loading files. Useful for scripting or one-off operations.

-p client-id
    Send keys to a specific client. Primarily used for programmatic interaction or scripting.

-n
    Do not load the user's kakrc configuration file at startup. Useful for troubleshooting.

-q
    Run in quiet mode, suppressing diagnostic messages during startup.

DESCRIPTION

Kakoune (often invoked as kak) is a modern, open-source, modal code editor that aims to improve on the Vim editing model. Its core philosophy is 'selection first', meaning you select text or a range of lines before applying an action, which often provides interactive previews. Unlike Vim, where commands operate on an implicit selection or cursor position, Kakoune makes selections explicit and central to its workflow. It features multiple concurrent selections, allowing efficient parallel editing. Kakoune is built with a client-server architecture, enabling multiple windows/terminals to connect to the same editing session. It's highly extensible through shell scripting, offering a powerful and flexible editing environment for programmers.

CAVEATS

Users accustomed to traditional editors (e.g., VS Code, Sublime Text) will find Kakoune's modal editing and 'selection first' paradigm to have a significant learning curve. Even Vim users might need to adapt to its distinct command model. Being a terminal-based editor, it lacks GUI features, relying on external tools for certain advanced functionalities like integrated debuggers or rich graphical interfaces for plugins. Its community and plugin ecosystem, while active, are smaller compared to Vim or Emacs.

CLIENT-SERVER ARCHITECTURE

Kakoune uses a client-server model, where a single server process manages editing sessions, and multiple clients (terminal windows) can connect to the same session. This allows for persistent editing sessions, collaborative editing by connecting multiple clients to the same session, and easy recovery from terminal disconnections.

MULTIPLE SELECTIONS

A defining feature of Kakoune is its robust support for multiple, simultaneous selections. Users can easily create and manipulate multiple selections, allowing them to apply the same editing command to disparate parts of a file efficiently, significantly boosting productivity for repetitive tasks.

EXTENSIBILITY

Kakoune is highly extensible and configurable. Its configuration is done via a simple scripting language, often leveraging standard shell commands. This allows users to deeply customize keybindings, integrate external tools, and create complex macros without needing to learn a proprietary language.

HISTORY

Kakoune development was started by Maxime Chevalier-Boisvert around 2013, with the goal of rethinking the Vim editing model. It aims to improve on Vim's core ideas by making selections explicit and central to the editing workflow, often providing interactive previews of changes. The editor is written in C++ and has steadily gained a following among users who appreciate its fresh take on modal editing, its powerful multiple selection capabilities, and its client-server architecture which allows seamless session management across multiple terminals.

SEE ALSO

vim(1), nvim(1), emacs(1)

Copied to clipboard