image:https://rawgit.com/mawww/kakoune/master/doc/kakoune_logo.svg[K,30,30] Kakoune image:https://travis-ci.org/mawww/kakoune.svg[link="https://travis-ci.org/mawww/kakoune"] ============================================================================================================================================================================= TL;DR ----- *Vim inspired* -- *Faster as in less keystrokes* -- *Multiple selections* -- *Orthogonal design* --------------------------------------------- git clone http://github.com/mawww/kakoune.git cd kakoune/src make make userconfig ./kak --------------------------------------------- See http://github.com/mawww/golf for kakoune solutions to vimgolf challenges, regularly beating the best vim solution. Introduction: ------------- Kakoune is a code editor heavily inspired by Vim, as such most of it's commands are similar to vi's ones. 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. see http://vimeo.com/82711574 Join us on freenode 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 or your X11 window manager to manage windows * 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 Building -------- Kakoune dependencies are: * A C++11 compliant compiler (GCC >= 4.8.1 or clang >= 3.4) * boost (>= 1.50) * ncurses with wide-characters support (>= 5.3, generally refered as libncursesw) To build, just type *make* in the src directory Kakoune can be built on Linux, MacOS, and Cygwin. Due to Kakoune relying heavily on being in an Unix like environment, no native Windows version is planned. To setup a basic configuration on your account, type *make userconfig* in the src directory, this will setup an initial $XDG_CONFIG_HOME/kak directory. See the _Kakrc_ section for more information. Installing ---------- In order to install kak on your system, rather than running it directly from it's source directory, type *make install*, you can specify the +PREFIX+ and +DESTDIR+ if needed. Note that by default, no script files will be read if you do not add links to them in $XDG_CONFIG_HOME/kak/autoload. Available script files will be installed in $PREFIX/share/kak/rc If you want to enable all files, set $XDG_CONFIG_HOME/kak/autoload to be a symbolic link to the $PREFIX/share/kak/rc directory. ---------------------------------------------- ln -s /usr/share/kak/rc ~/.config/kak/autoload ---------------------------------------------- Homebrew (OSX) ~~~~~~~~~~~~~~ ----------------------------------------------------------------------------------------------- brew install --HEAD https://raw.githubusercontent.com/mawww/kakoune/homebrew/contrib/kakoune.rb ----------------------------------------------------------------------------------------------- Fedora 20/21/22/Rawhide & Epel 7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Use created copr repository https://copr.fedoraproject.org/coprs/jkonecny/kakoune/ --------------------------------- dnf copr enable jkonecny/kakoune dnf install kakoune --------------------------------- Exherbo ~~~~~~~ -------------------------------- cave resolve -x repository/mawww cave resolve -x kakoune -------------------------------- Running ------- Just running *kak* launch a new kak session with a client on local terminal. *kak* accepts some switches: * +-c +: connect to given session, sessions are unix sockets +/tmp/kak-+ * +-e +: execute commands on startup * +-n+: ignore kakrc file * +-s +: set the session name, by default it will be the pid of the initial kak process. * +-d+: run Kakoune in daemon mode, without user interface. This requires the session name to be specified with -s. In this mode, the Kakoune server will keep running even if there is no connected client, and will quit when receiving SIGTERM. * +-p +: read stdin, and then send its content to the given session acting as a remote control. * +-f +: Work as a filter, read every file given on the command line and stdin if piped in, and apply given keys on each. At startup, if +-n+ is not specified, Kakoune will try to source the file ../share/kak/kakrc relative to the kak binary. This kak file will then try to source any files in $XDG_CONFIG_HOME/kak/autoload (with $XDG_CONFIG_HOME defaulting to $HOME/.config), and finally $XDG_CONFIG_HOME/kak/kakrc. The common pattern is to add links to $XDG_CONFIG_HOME/kak/autoload to the scripts in $PREFIX/share/kak/rc that the user wants sourced at kak launch. Basic Movement -------------- * +h+: select the character on the right of selection end * +j+: select the character below the selection end * +k+: select the character above the selection end * +l+: select the character on the left of selection end * +w+: select the word and following whitespaces on the right of selection end * +b+: select preceding whitespaces and the word on the left of selection end * +e+: select preceding whitespaces and the word on the right of selection end * +alt-[wbe]+: same as [wbe] but select WORD instead of word * +x+: select line on which selection end lies (or next line when end lies on an end-of-line) * +alt-x+: expand selections to contain full lines (including end-of-lines) * +alt-X+: trim selections to only contain full lines (not including last end-of-line) * +%+: select whole buffer * +alt-H+: select to line begin * +alt-L+: select to line end * +/+: search (select next match) * +?+: search (extend to next match) * +n+: select next match * +N+: add a new selection with next match * +alt-n+: select previous match * +alt-N+: add a new selection with previous match * +pageup+: scroll up * +pagedown+: scroll down * +alt-r+: rotate selections (the main selection becomes the next one) * +;+: reduce selections to their cursor * +alt-;+: flip the selections direction * +alt-:+: ensure selections are in forward direction (cursor after anchor) A word is a sequence of alphanumeric characters or underscore, a WORD is a sequence of non whitespace characters. Appending --------- for most selection commands, using shift permits to extend current selection instead of replacing it. for example, +wWW+ selects 3 consecutive words Using Counts ------------ Most selection commands also support counts, which are entered before the command itself. for example, +3W+ selects 3 consecutive words and +3w+ select the third word on the right of selection end. Changes ------- * +i+: insert before current selection * +a+: insert after current selection * +d+: yank and delete current selection * +c+: yank and delete current selection and insert * +.+: repeat last insert mode change (+i+, +a+, or +c+, including the inserted text) * +I+: insert at current selection begin line start * +A+: insert at current selection end line end * +o+: insert in a new line below current selection end * +O+: insert in a new line above current selection begin * +y+: yank selections * +p+: paste after current selection end * +P+: paste before current selection begin * +alt-p+: paste all after current selection end, and select each pasted string. * +alt-P+: paste all before current selection begin, and select each pasted string. * +R+: replace current selection with yanked text * +r+: replace each character with the next entered one * +alt-j+: join selected lines * +alt-J+: join selected lines and select spaces inserted in place of line breaks * +>+: indent selected lines * +<+: deindent selected lines * +alt->+: indent selected lines, including empty lines * +<+: deindent selected lines * +alt-<+: deindent selected lines, do not remove incomplete indent (3 leading spaces when indent is 4) * +|+: pipe each selections through the given external filter program and replace the selection with it's output. * +alt-|+: pipe each selections through the given external filter program and ignore its output * +!+: insert command output before selection * +a-!+: append command output after selection * +u+: undo last change * +U+: redo last change * +&+: align selection, align the cursor of selections by inserting spaces before the first character of the selection * +alt-&+: copy indent, copy the indentation of the main selection (or the count one if a count is given) to all other ones * +`+: to lower case * +~+: to upper case * +alt-`+: swap case * +@+: convert tabs to spaces in current selections, uses the buffer tabstop option or the count parameter for tabstop. * +alt-@+: convert spaces to tabs in current selections, uses the buffer tabstop option or the count parameter for tabstop. * +alt-R+: rotate selections content, if specified, the count groups selections, so +3+ rotate (1, 2, 3) and (3, 4, 6) independently. Goto Commands ------------- Commands begining with g are used to goto certain position and or buffer: * +gh+: select to line begin * +gl+: select to line end * +gg+, +gk+: go to the first line * +gj+: go to the last line * +gt+: go to the first displayed line * +gc+: go to the middle displayed line * +gb+: go to the last displayed line * +ga+: go to the previous (alternate) buffer * +gf+: open the file whose name is selected * +g.+: go to last buffer modifiction position View commands ------------- Some commands, all begining with v permit to manipulate the current view. * +vv+ or +vc+: center the main selection in the window * +vt+: scroll to put the main selection on the top line of the window * +vb+: scroll to put the main selection on the bottom line of the window * +vh+: scroll the window count columns left * +vj+: scroll the window count line downward * +vk+: scroll the window count line upward * +vl+: scroll the window count columns right Jump list --------- Some commands, like the goto commands, buffer switch or search commands, push the previous selections to the client's jump list. It is possible to forward or backward in the jump list using: * +control-i+: Jump forward * +control-o+: Jump backward * +control-s+: save current selections Multi Selection --------------- Kak was designed from the start to handle multiple selections. One way to get a multiselection is via the +s+ key. For example, to change all occurences of word 'roger' to word 'marcel' in a paragraph, here is what can be done: select the paragraph with enough +x+. press +s+ and enter roger then enter. now paragraph selection was replaced with multiselection of each roger in the paragraph. press +c+ and marcel to replace rogers with marcels. A multiselection can also be obtained with +S+, which splits the current selection according to the regex entered. To split a comma separated list, use +S+ then ', *' +s+ and +S+ share the search pattern with +/+, and hence entering an empty pattern uses the last one. As a convenience, +alt-s+ allows you to split the current selections on line boundaries. To clear multiple selections, use +space+. To keep only the nth selection use +n+ followed by +space+, in order to remove a selection, use +alt-space+. +alt-k+ allows you to enter a regex and keep only the selections that contains a match for this regex. using +alt-K+ you can keep the selections not containing a match. +C+ copies the current selection to the next line (or lines if a count is given) +alt-C+ does the same to previous lines. +$+ allows you to enter a shell command and pipe each selections to it. Selections whose shell command returns 0 will be kept, other will be dropped. Object Selection ---------------- Some keys allow you to select a text object: * +alt-a+: selects the whole object * +alt-i+: selects the inner object, that is the object excluding it's surrounder. for example, for a quoted string, this will not select the quote, and for a word this will not select trailing spaces. * +[+: selects to object start * +]+: selects to object end * +{+: extends selections to object start * +}+: extends selections to object end After this key, you need to enter a second key in order to specify which object you want. * +b+, +(+ or +)+: select the enclosing parenthesis * +B+, +{+ or +}+: select the enclosing {} block * +r+, +[+ or +]+: select the enclosing [] block * +a+, +<+ or +>+: select the enclosing <> block * +"+: select the enclosing double quoted string * +'+: select the enclosing single quoted string * +`+: select the enclosing grave quoted string * +w+: select the whole word * +W+: select the whole WORD * +s+: select the sentence * +p+: select the paragraph * +␣+: select the whitespaces * +i+: select the current indentation block * +n+: select the number For nestable objects, a count can be used in order to specify which surrounding level to select. Registers --------- registers are named list of text. They are used for various purpose, like storing the last yanked test, or the captures groups associated with the selections. While in insert mode, ctrl-r followed by a register name (one character) inserts it. For example, ctrl-r followed by " will insert the currently yanked text. ctrl-r followed by 2 will insert the second capture group from the last regex selection. Registers are lists, instead of simply text in order to interact well with multiselection. Each selection have it's own captures, or yank buffer. Macros ------ Kakoune can record and replay a sequence of key press. When pressing the +Q+ key, followed by an alphabetic key for the macro name, Kakoune begins macro recording: every pressed keys will be added to the macro until the +Q+ key is pressed again. To replay a macro, use the +q+ key, followed by the macro name. Search selection ---------------- Using the +*+ key, you can set the search pattern to the current selection. This tries to be intelligent. It will for example detect if current selection begins and/or end at word boundaries, and set the search pattern accordingly. with +alt-*+ you can set the search pattern to the current seletion without Kakoune trying to be smart. Basic Commands -------------- Commands are entered using +:+. * +e[dit] [ []]+: open buffer on file, go to given line and column. If file is already opened, just switch to this file. use edit! to force reloading. * +w[rite] []+: write buffer to or use it's name if filename is not given. * +w[rite]a[ll]+: write all buffers that are associated to a file. * +q[uit]+: exit Kakoune, use quit! to force quitting even if there is some unsaved buffers remaining. * +wq+: write current buffer and quit * +b[uffer] +: switch to buffer * +d[el]b[uf] []+: delete the buffer , use d[el]b[uf]! to force deleting a modified buffer. * +source +: execute commands in * +runtime +: execute commands in , is relative to kak executable path. * +nameclient +: set current client name * +namebuf +: set current buffer name * +echo +: show in status line * +nop+: does nothing, but as with every other commands, arguments may be evaluated. So nop can be used for example to execute a shell command while being sure that it's output will not be interpreted by kak. +:%sh{ echo echo tchou }+ will echo tchou in Kakoune, whereas +:nop %sh{ echo echo tchou }+ will not, but both will execute the shell command. Exec and Eval ------------- the +:exec+ and +:eval+ commands can be used for running Kakoune commands. +:exec+ keys as if they were pressed, whereas +:eval+ executes it's given paremeters as if they were entered in the command prompt. By default, they do their execution in the context of the current client. Some parameters provide a way to change the context of execution: * +-client +: execute in the context of the client named * +-try-client +: execute in the context of the client named if such client exists, or else in the current context. * +-draft+: execute in a copy of the context of the selected client modifications to the selections or input state will not affect the client. This permits to make some modification to the buffer without modifying the user's selection. * +-itersel+ (requires +-draft+): execute once per selection, in a context with only the considered selection. This permits to avoid cases where the selections may get merged. * +-buffer +: execute in the context of each buffers in the comma separated list * +-no-hooks+: disable hook execution while executing the keys/commands The execution stops when the last key/command is reached, or an error is raised. key parameters gets concatenated, so the following commands are equivalent. ---------------------- :exec otest1 :exec o test 1 ---------------------- String syntax ------------- When entering a command, parameters are separated by whitespace (shell like), if you want to give parameters with spaces, you should quote them. Kakoune support three string syntax: * +\'strings\'+: uninterpreted strings, you can use \' to escape the separator, every other char is itself. * +"strings"+: expended strings, % strings (see %sh, %opt or %reg) contained are expended. Use \% to escape a % inside them, and \\ to escape a slash. * +%\{strings\}+: these strings are very useful when entering commands - the '{' and '}' delimiter are configurable: you can use any non alphanumeric character. like %[string], %, %(string), %~string~ or %!string!... - if the character following the % is one of {[(<, then the closing one is the matching }])> and the delimiters are not escapable but are nestable. for example +%{ roger {}; }+ is a valid string, +%{ marcel \}+ as well. Options ------- For user configuration, Kakoune supports options. Options are typed, their type can be * +int+: an integer number * +bool+: a boolean value, +yes/true+ or +no/false+ * +yesnoask+: similar to a boolean, but the additional value +ask+ is supported. * +str+: a string, some freeform text * +coord+: a line,column pair (separated by comma) * +regex+: as a string but the +set+ commands will complain if the entered text is not a valid regex. * +{int,str}-list+: a list, elements are separated by a colon (:) if an element needs to contain a colon, it can be escaped with a backslash. Options value can be changed using the +set+ commands: -------------------------------------------------------------- :set [global,buffer,window]