2011-11-04 10:09:27 +01:00
|
|
|
Kakoune
|
|
|
|
=======
|
|
|
|
|
|
|
|
Introduction:
|
|
|
|
-------------
|
|
|
|
|
2011-11-04 15:05:05 +01:00
|
|
|
Kakoune is a code editor heavily inspired by vim, as such most of it's
|
2011-11-04 10:09:27 +01:00
|
|
|
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.
|
|
|
|
|
|
|
|
There is no concept of cursor in kakoune, only selections, a single character
|
2011-12-28 20:04:57 +01:00
|
|
|
selection can be seen as a cursor but there is no difference internally.
|
2011-11-04 10:09:27 +01:00
|
|
|
|
2011-11-04 15:05:05 +01:00
|
|
|
Building
|
|
|
|
--------
|
|
|
|
|
|
|
|
Kakoune dependencies are:
|
2011-11-04 15:28:29 +01:00
|
|
|
|
2012-08-05 13:09:08 +02:00
|
|
|
* GCC >= 4.7
|
2011-11-04 15:05:05 +01:00
|
|
|
* boost
|
|
|
|
* ncurses
|
|
|
|
|
|
|
|
To build, just type *make* in the src directory
|
2011-11-04 10:09:27 +01:00
|
|
|
|
2013-01-04 18:32:26 +01:00
|
|
|
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.
|
|
|
|
|
2013-01-07 14:25:19 +01:00
|
|
|
Running
|
|
|
|
-------
|
|
|
|
|
|
|
|
Just running *kak* launch a new kak session with a client on local terminal.
|
|
|
|
*kak* accepts some switches:
|
|
|
|
|
|
|
|
* +-c <session>+: connect to given session (which is the pid of the
|
|
|
|
initial kak process), sessions are unix sockets +/tmp/kak-<session>+
|
|
|
|
* +-e <commands>+: execute commands on startup
|
|
|
|
* +-n+: ignore kakrc file
|
|
|
|
|
2011-11-04 10:09:27 +01:00
|
|
|
Basic Movement
|
|
|
|
--------------
|
|
|
|
|
|
|
|
* _space_: select the character under selection end
|
2013-01-03 14:01:48 +01:00
|
|
|
* _alt-space_: flip the selections
|
2011-11-04 10:09:27 +01:00
|
|
|
|
|
|
|
* _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
|
|
|
|
|
2011-12-28 20:04:57 +01:00
|
|
|
* _w_: select the word and following whitespaces on the right of selection end
|
2011-11-04 10:09:27 +01:00
|
|
|
* _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
|
2013-01-03 14:01:48 +01:00
|
|
|
* _alt-[wbe]_: same as [wbe] but select WORD instead of word
|
2011-11-04 10:09:27 +01:00
|
|
|
|
2011-11-22 15:32:05 +01:00
|
|
|
* _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)
|
|
|
|
|
2011-11-04 10:09:27 +01:00
|
|
|
* _%_: select whole buffer
|
|
|
|
|
2012-05-29 13:32:29 +02:00
|
|
|
* _gh_, _alt-H_: select to line begin
|
|
|
|
* _gl_, _alt-L_: select to line end
|
|
|
|
|
|
|
|
* _gg_, _gt_: go to the first line
|
|
|
|
* _gb_: go to the last line
|
2011-11-04 10:09:27 +01:00
|
|
|
|
2013-01-03 14:01:48 +01:00
|
|
|
* _/_: search (select next match)
|
|
|
|
* _?_: search (extend to next match)
|
|
|
|
* _n_: select next match
|
2012-10-16 18:53:05 +02:00
|
|
|
* _N_: add a new selection with next match
|
2013-03-20 19:10:16 +01:00
|
|
|
* _alt-n_: replace main selection with next match (preserving the others)
|
2013-01-03 14:01:48 +01:00
|
|
|
|
2013-03-20 19:10:16 +01:00
|
|
|
* _alt-c_: center main selection in current window
|
2013-01-03 14:01:48 +01:00
|
|
|
* _pageup_: scroll up
|
|
|
|
* _pagedown_: scroll down
|
2012-10-16 18:53:05 +02:00
|
|
|
|
2011-11-04 10:09:27 +01:00
|
|
|
Appending
|
|
|
|
---------
|
|
|
|
|
2013-01-03 14:01:48 +01:00
|
|
|
for most selection commands, using shift permits to extend current selection
|
2011-11-04 10:09:27 +01:00
|
|
|
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.
|
|
|
|
|
2012-08-08 00:11:36 +02:00
|
|
|
* _space_: when used with count, keep only the counth selection
|
|
|
|
* _alt-space_: when used with count, remove the counth selection
|
2012-05-29 13:32:29 +02:00
|
|
|
|
2011-11-04 10:09:27 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
* _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
|
|
|
|
|
|
|
|
* _p_: paste after current selection end
|
|
|
|
* _P_: paste before current selection begin
|
2013-01-03 14:01:48 +01:00
|
|
|
* _alt-p_: replace current selection with yanked text
|
2011-11-04 10:09:27 +01:00
|
|
|
|
2011-11-22 15:32:05 +01:00
|
|
|
* _alt-j_: join selected lines
|
|
|
|
|
2013-01-03 14:01:48 +01:00
|
|
|
* _>_: indent selected lines
|
|
|
|
* _<_: deindent selected lines
|
|
|
|
|
2011-12-28 20:09:54 +01:00
|
|
|
* _|_: pipe each selections through the given external filter program
|
|
|
|
and replace with it's output.
|
|
|
|
|
2013-01-03 14:01:48 +01:00
|
|
|
* _u_: undo last change
|
|
|
|
* _U_: redo last change
|
|
|
|
|
2011-11-16 15:15:40 +01:00
|
|
|
Multi Selection
|
|
|
|
---------------
|
|
|
|
|
|
|
|
Kak was designed from the start to handle multiple selections.
|
2012-10-16 18:53:05 +02:00
|
|
|
One way to get a multiselection is via the _s_ key.
|
2011-11-16 15:15:40 +01:00
|
|
|
|
|
|
|
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<esc> to replace rogers with marcels.
|
|
|
|
|
2013-02-22 18:37:34 +01:00
|
|
|
A multiselection can also be obtained with _S_, which splits the current
|
2011-11-21 20:35:02 +01:00
|
|
|
selection according to the regex entered. To split a comma separated list,
|
2013-02-22 18:37:34 +01:00
|
|
|
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.
|
2011-11-21 20:35:02 +01:00
|
|
|
|
2012-05-04 06:34:48 +02:00
|
|
|
To clear multiple selections, use _space_. To keep only the nth selection
|
2012-11-12 19:41:50 +01:00
|
|
|
use _n_ followed by _space_, to remove only the nth selection, use _n_
|
|
|
|
followed by _alt-space_.
|
2012-01-25 22:26:41 +01:00
|
|
|
|
2012-05-29 13:32:29 +02:00
|
|
|
Object Selection
|
|
|
|
----------------
|
|
|
|
|
2013-03-14 14:11:06 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
After this key, you need to enter a second key in order to specify which
|
|
|
|
object you want.
|
2012-05-29 13:32:29 +02:00
|
|
|
|
2012-08-08 00:11:36 +02:00
|
|
|
* _b_, _(_ or _)_: select the enclosing parenthesis
|
|
|
|
* _B_, _{_ or _}_: select the enclosing {} block
|
2013-03-18 22:31:05 +01:00
|
|
|
* _r_, _[_ or _]_: select the enclosing [] block
|
2012-08-08 00:11:36 +02:00
|
|
|
* _<_ or _>_: select the enclosing <> block
|
2013-03-14 14:11:06 +01:00
|
|
|
* _"_: select the enclosing double quoted string
|
|
|
|
* _'_: select the enclosing single quoted string
|
|
|
|
* _w_: select the whole word
|
|
|
|
* _W_: select the whole WORD
|
2012-05-29 13:32:29 +02:00
|
|
|
|
2012-02-10 15:18:17 +01:00
|
|
|
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
|
2013-03-20 19:10:16 +01:00
|
|
|
selections.
|
2012-02-10 15:18:17 +01:00
|
|
|
|
|
|
|
While in insert mode, ctrl-r followed by a register name (one character)
|
|
|
|
inserts it.
|
2011-11-16 21:05:51 +01:00
|
|
|
|
2012-02-10 15:18:17 +01:00
|
|
|
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.
|
2011-11-16 21:05:51 +01:00
|
|
|
|
2012-02-10 15:18:17 +01:00
|
|
|
Registers are lists, instead of simply text in order to interact well with
|
|
|
|
multiselection. Each selection have it's own captures, or yank buffer.
|
2011-11-16 21:05:51 +01:00
|
|
|
|
2013-02-19 19:04:09 +01:00
|
|
|
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.
|
|
|
|
|
2012-08-08 00:11:36 +02:00
|
|
|
Basic Commands
|
|
|
|
--------------
|
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
Commands are entered using +:+.
|
2012-08-08 00:11:36 +02:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
* +e[dit] <filename> [<line> [<column>]]+: open buffer on file, go to given
|
2012-08-08 00:11:36 +02:00
|
|
|
line and column. If file is already opened, just switch to this file.
|
|
|
|
use edit! to force reloading.
|
2012-09-12 19:28:38 +02:00
|
|
|
* +w[rite] [<filename>]+: write buffer to <filename> or use it's name if
|
2012-08-08 00:11:36 +02:00
|
|
|
filename is not given.
|
2012-09-12 19:28:38 +02:00
|
|
|
* +q[uit]+: exit Kakoune, use quit! to force quitting even if there is some
|
2012-08-08 00:11:36 +02:00
|
|
|
unsaved buffers remaining.
|
2012-09-12 19:28:38 +02:00
|
|
|
* +wq+: write current buffer and quit
|
|
|
|
* +b[uffer] <name>+: switch to buffer <name>
|
2013-01-03 14:01:48 +01:00
|
|
|
* +d[el]b[uf] [<name>]+: delete the buffer <name>, use d[el]b[uf]! to force
|
|
|
|
deleting a modified buffer.
|
2012-09-12 19:28:38 +02:00
|
|
|
* +source <filename>+: execute commands in <filename>
|
|
|
|
* +runtime <filename>+: execute commands in <filename>, <filename>
|
2012-08-08 00:11:36 +02:00
|
|
|
is relative to kak executable path.
|
2013-01-03 14:01:48 +01:00
|
|
|
* +name <name>+: set current client name
|
|
|
|
* +exec [-client <name>] <keys>+: execute <keys> as if pressed in normal mode.
|
|
|
|
if client if specified, exec keys in the named client context.
|
|
|
|
* +eval [-client <name>] <command>+: execute <command> as if entered in command line
|
|
|
|
if client if specified, exec command in the named client context.
|
2012-09-12 19:28:38 +02:00
|
|
|
* +echo <text>+: show <text> in status line
|
2013-03-14 14:11:06 +01:00
|
|
|
* +decl <type> <name> [<value>]+: declare an option, type can be int, str, int-list
|
|
|
|
and str-list.
|
2012-10-16 18:53:05 +02:00
|
|
|
* +set{b,w,g} <option> <value>+: set <option> to <value> in *b*uffer, *w*indow
|
2012-08-08 00:11:36 +02:00
|
|
|
or *g*lobal scope.
|
2013-03-14 14:11:06 +01:00
|
|
|
* +name <name>+: sets current client name to name
|
2013-01-03 14:01:48 +01:00
|
|
|
* +c[ol]a[lias] <name> <colspec>+: define a color alias, so that name can be
|
|
|
|
used instead of colspec in contexts where a color is needed.
|
2013-01-03 18:52:07 +01:00
|
|
|
* +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.
|
2013-01-03 18:57:30 +01:00
|
|
|
+:%sh{ echo echo tchou }+ will echo tchou in kakoune, whereas
|
|
|
|
+:nop %sh{ echo echo tchou }+ will not, but both will execute the
|
2013-01-03 18:52:07 +01:00
|
|
|
shell command.
|
2012-08-08 00:11:36 +02:00
|
|
|
|
|
|
|
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:
|
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
* +"strings" and \'strings\'+: classic strings, use \' or \" to escape the
|
|
|
|
separator.
|
2012-08-08 00:11:36 +02:00
|
|
|
|
2013-02-19 19:04:09 +01:00
|
|
|
* +%\{strings\}+: these strings are very useful when entering commands
|
2012-09-12 19:28:38 +02:00
|
|
|
|
|
|
|
- the '{' and '}' delimiter are configurable: you can use any non
|
|
|
|
alphanumeric character. like %[string], %<string>, %(string), %~string~
|
|
|
|
or %!string!...
|
|
|
|
- if the character following the % is one of {[(<, then
|
|
|
|
the closing one is the matching }])>, and these delimiters in the string
|
|
|
|
need not to be escaped if the contained delimiters are balanced.
|
|
|
|
for example +%{ roger {}; }+ is a valid string.
|
2012-08-08 00:11:36 +02:00
|
|
|
|
2011-11-29 23:37:20 +01:00
|
|
|
Highlighters
|
|
|
|
------------
|
2011-11-08 15:30:10 +01:00
|
|
|
|
2011-11-29 23:37:20 +01:00
|
|
|
Manipulation of the displayed text is done through highlighters, which can be added
|
2012-09-12 19:28:38 +02:00
|
|
|
or removed with the command
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
-----------------------------------------------------
|
|
|
|
:addhl <highlighter_name> <highlighter_parameters...>
|
|
|
|
-----------------------------------------------------
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
and
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
----------------------
|
|
|
|
:rmhl <highlighter_id>
|
|
|
|
----------------------
|
2011-11-08 15:30:10 +01:00
|
|
|
|
2011-11-29 23:37:20 +01:00
|
|
|
existing highlighters are:
|
2011-11-08 15:30:10 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
* +number_lines+: show line numbers
|
2013-03-14 14:11:06 +01:00
|
|
|
* +group <group_name>+: highlighter group, containing other highlighters.
|
|
|
|
useful when multiple highlighters work together and need to be
|
|
|
|
removed as one. Adding and removing from a group can be done using
|
|
|
|
`:addhl -group <group> <highlighter_name> <highlighter_parameters...>`
|
|
|
|
`:rmhl -group <group> <highlighter_name>`
|
|
|
|
* +regex <ex> <color>...+: highlight a regex, takes the regex as first parameter,
|
|
|
|
followed by any number of color parameters. color format is:
|
|
|
|
<capture_id>:<fg_color>[,<bg_color>]
|
|
|
|
For example: `:addhl regex //(\h+TODO:)?[^\n]+ 0:cyan 1:yellow,red`
|
|
|
|
will highlight C++ style comments in cyan, with an eventual 'TODO:' in
|
|
|
|
yellow on red background.
|
|
|
|
* +search <color>+: highlight every matches to the current search pattern. takes
|
|
|
|
one parameter for the color to apply to highlighted elements.
|
|
|
|
* +flag_lines <flag> <option_name>+: add a column in front of text, and display the
|
|
|
|
given flag in it for everly lines contained in the int-list option named
|
|
|
|
<option_name>.
|
2011-11-26 20:19:08 +01:00
|
|
|
|
2011-12-02 15:30:10 +01:00
|
|
|
Filters
|
|
|
|
-------
|
|
|
|
|
|
|
|
Filters can be installed to interact with buffer modifications. They can be
|
2012-09-12 19:28:38 +02:00
|
|
|
added or removed with
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
-----------------------------------------------
|
|
|
|
:addfilter <filter_name> <filter_parameters...>
|
|
|
|
-----------------------------------------------
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
and
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
---------------------
|
2011-12-02 15:30:10 +01:00
|
|
|
:rmfilter <filter_id>
|
2012-09-12 19:28:38 +02:00
|
|
|
---------------------
|
2011-12-02 15:30:10 +01:00
|
|
|
|
|
|
|
exisiting filters are:
|
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
* +preserve_indent+: insert previous line indent when inserting a newline
|
|
|
|
* +cleanup_whitespaces+: remove trailing whitespaces on the previous line
|
2013-03-14 14:11:06 +01:00
|
|
|
when inserting an end-of-line.
|
2012-09-12 19:28:38 +02:00
|
|
|
* +expand_tabulations+: insert spaces instead of tab characters
|
2013-03-14 14:11:06 +01:00
|
|
|
* +regex <line_regex> <insert_regex> <replacement>+: when the current line regex
|
|
|
|
and inserted text regex matches, replace insereted text with the
|
|
|
|
replacement text. Capture groups are available through $[0-9] escape
|
|
|
|
sequence, and cursor position can be specified with $c.
|
2012-09-12 19:28:38 +02:00
|
|
|
* +group+: same as highlighters group
|
2011-12-02 15:30:10 +01:00
|
|
|
|
2011-11-26 20:19:08 +01:00
|
|
|
Hooks
|
|
|
|
-----
|
|
|
|
|
|
|
|
commands can be registred to be executed when certain events arise.
|
|
|
|
to register a hook, use the hook command.
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
------------------------------------------------------
|
2012-08-08 00:11:36 +02:00
|
|
|
:hook <scope> <hook_name> <filtering_regex> <commands>
|
2012-09-12 19:28:38 +02:00
|
|
|
------------------------------------------------------
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-06-15 14:24:09 +02:00
|
|
|
<scope> can be either global, buffer or window, the scope are hierarchical,
|
|
|
|
meaning that a Window calling a hook will execute it's own, the buffer ones
|
|
|
|
and the global ones.
|
2011-11-26 20:19:08 +01:00
|
|
|
|
2012-08-08 00:11:36 +02:00
|
|
|
<command> is a string containing the commands to execute when the hook is
|
|
|
|
called.
|
|
|
|
|
2012-01-25 22:26:41 +01:00
|
|
|
for example, to automatically use line numbering with .cc files,
|
2011-11-26 20:19:08 +01:00
|
|
|
use the following command:
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
-----------------------------------------------------
|
2012-08-08 00:11:36 +02:00
|
|
|
:hook global WinCreate .*\.cc %{ addhl number_lines }
|
2012-09-12 19:28:38 +02:00
|
|
|
-----------------------------------------------------
|
2012-01-25 22:26:41 +01:00
|
|
|
|
2013-03-20 19:10:16 +01:00
|
|
|
existing hooks are:
|
|
|
|
|
|
|
|
* +NormalIdle+: A certain duration has passed since last key was pressed in
|
|
|
|
normal mode.
|
|
|
|
* +NormalBegin+: Entering normal mode
|
|
|
|
* +NormalEnd+: Leaving normal mode
|
|
|
|
* +NormalKey+: A key is received in normal mode, the key is used for filtering
|
|
|
|
* +InsertIdle+: A certain duration has passed since last key was pressed in
|
|
|
|
insert mode.
|
|
|
|
* +InsertBegin+: Entering insert mode
|
|
|
|
* +InsertEnd+: Leaving insert mode
|
|
|
|
* +InsertKey+: A key is received in insert mode, the key is used for filtering
|
|
|
|
* +InsertMove+: The cursor moved (without inserting) in insert mode, the key
|
|
|
|
that triggered the move is used for filtering
|
2013-03-22 13:41:48 +01:00
|
|
|
* +WinCreate+: A window was created, the filtering text is the buffer name
|
|
|
|
* +WinDisplay+: A window was bound a client, the filtering text is the buffer
|
|
|
|
name
|
2013-03-20 19:10:16 +01:00
|
|
|
* +WinSetOption+: An option was set in a window context, the filtering text
|
|
|
|
is '<option_name>=<new_value>'
|
|
|
|
* +BufNew+: A buffer for a new file has been created, filename is used for
|
|
|
|
filtering
|
|
|
|
* +BufOpen+: A buffer for an existing file has been created, filename is
|
|
|
|
used for filtering
|
|
|
|
* +BufCreate+: A buffer has been created, filename is used for filtering
|
|
|
|
* +RuntimeError+: an error was encountered while executing an user command
|
|
|
|
the error message is used for filtering
|
|
|
|
|
|
|
|
when not specified, the filtering text is an empty string.
|
|
|
|
|
2012-08-08 00:11:36 +02:00
|
|
|
Shell expansion
|
2012-05-29 13:32:29 +02:00
|
|
|
---------------
|
|
|
|
|
2012-08-08 00:11:36 +02:00
|
|
|
A special string syntax is supported which replace it's content with the
|
|
|
|
output of the shell commands in it, it is similar to the shell $(...)
|
|
|
|
syntax and is evaluated only when needed.
|
|
|
|
for example: %sh{ ls } is replaced with the output of the ls command.
|
|
|
|
|
|
|
|
Some of kakoune state is available through environment variables:
|
|
|
|
|
2013-03-20 19:10:16 +01:00
|
|
|
* +kak_selection+: content of the main selection
|
2013-03-21 19:10:18 +01:00
|
|
|
* +kak_selections+: content of the selection separated by commas
|
2012-09-12 19:28:38 +02:00
|
|
|
* +kak_bufname+: name of the current buffer
|
2013-03-14 14:11:06 +01:00
|
|
|
* +kak_timestamp+: timestamp of the current buffer, the timestamp is an
|
|
|
|
integer value which is incremented each time the buffer is modified.
|
2012-09-12 19:28:38 +02:00
|
|
|
* +kak_runtime+: directory containing the kak binary
|
2013-03-14 14:11:06 +01:00
|
|
|
* +kak_opt_<name>+: value of option <name>
|
|
|
|
* +kak_reg_<r>+: value of register <r>
|
2013-01-07 14:25:19 +01:00
|
|
|
* +kak_socket+: filename of session socket (/tmp/kak-<session>)
|
|
|
|
* +kak_client+: name of current client
|
2013-03-20 19:10:16 +01:00
|
|
|
* +kak_cursor_line+: line of the end of the main selection
|
|
|
|
* +kak_cursor_cursor+: column of the end of the main selection
|
|
|
|
* +kak_hook_param+: filtering text passed to the currently executing hook
|
2012-08-08 00:11:36 +02:00
|
|
|
|
|
|
|
for example you can print informations on the current file in the status
|
|
|
|
line using:
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
-------------------------------
|
2012-08-08 00:11:36 +02:00
|
|
|
:echo %sh{ ls -l $kak_bufname }
|
2012-09-12 19:28:38 +02:00
|
|
|
-------------------------------
|
2012-08-08 00:11:36 +02:00
|
|
|
|
2012-08-11 12:22:21 +02:00
|
|
|
Register and Option expansion
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
Similar to shell expansion, register contents and options values can be
|
|
|
|
accessed through %reg{<register>} and %opt{<option>} syntax.
|
|
|
|
|
|
|
|
for example you can display last search pattern with
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
-------------
|
2012-08-11 12:22:21 +02:00
|
|
|
:echo %reg{/}
|
2012-09-12 19:28:38 +02:00
|
|
|
-------------
|
2012-08-11 12:22:21 +02:00
|
|
|
|
2012-08-08 00:11:36 +02:00
|
|
|
Defining Commands
|
|
|
|
-----------------
|
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
new commands can be defined using the +def+ command.
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
------------------------------
|
2012-08-08 00:11:36 +02:00
|
|
|
:def <command_name> <commands>
|
2012-09-12 19:28:38 +02:00
|
|
|
------------------------------
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-08-08 00:11:36 +02:00
|
|
|
<commands> is a string containing the commands to execute
|
|
|
|
|
|
|
|
def can also takes some flags:
|
2012-09-12 19:28:38 +02:00
|
|
|
|
|
|
|
* +-env-params+: pass parameters given to commands in the environement as
|
2012-08-08 00:11:36 +02:00
|
|
|
kak_paramN with N the parameter number
|
2012-09-12 19:28:38 +02:00
|
|
|
* +-shell-params+: pass parameters given to commands as positional parameters
|
2012-09-11 13:54:43 +02:00
|
|
|
to any shell expansions used in the command.
|
2012-09-12 19:28:38 +02:00
|
|
|
* +-file-completion+: try file completion on any parameter passed
|
2012-09-12 14:21:42 +02:00
|
|
|
to this command
|
2012-09-12 19:28:38 +02:00
|
|
|
* +-shell-completion+: following string is a shell command which takes
|
2012-09-11 13:54:43 +02:00
|
|
|
parameters as positional params and output one
|
2012-08-08 00:11:36 +02:00
|
|
|
completion candidate per line.
|
2012-09-12 19:28:38 +02:00
|
|
|
* +-allow-override+: allow the new command to replace an exisiting one
|
2012-08-08 00:11:36 +02:00
|
|
|
with the same name.
|
|
|
|
|
|
|
|
Using shell expansion permits to define complex commands or to access
|
|
|
|
kakoune state:
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
------------------------------------------------------
|
2012-08-08 00:11:36 +02:00
|
|
|
:def print_selection %{ echo %sh{ ${kak_selection} } }
|
2012-09-12 19:28:38 +02:00
|
|
|
------------------------------------------------------
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-08-08 00:11:36 +02:00
|
|
|
Some helper commands can be used to define composite commands:
|
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
* +menu <label1> <commands1> <label2> <commands2>...+: display a menu using
|
2012-08-08 00:11:36 +02:00
|
|
|
labels, the selected label's commands are executed.
|
2013-01-03 14:01:48 +01:00
|
|
|
+menu+ can take a -auto-single argument, to automatically run commands
|
|
|
|
when only one choice is provided. and a -select-cmds argument, in which
|
|
|
|
case menu takes three argument per item, the last one being a command
|
|
|
|
to execute when the item is selected (but not validated).
|
2013-01-29 18:56:14 +01:00
|
|
|
* +info <text>+: display text in an information box, at can take a -anchor
|
|
|
|
option, which accepts +left+, +right+ and +cursor+ as value, in order to
|
2013-03-20 19:10:16 +01:00
|
|
|
specify where the info box should be anchored relative to the main selection.
|
2012-09-12 19:28:38 +02:00
|
|
|
* +try <commands> catch <on_error_commands>+: prevent an error in <commands>
|
2012-08-08 00:11:36 +02:00
|
|
|
from aborting the whole commands execution, execute <on_error_commands>
|
|
|
|
instead.
|
2013-03-18 22:43:48 +01:00
|
|
|
* +reg <name> <content>+: set register <name> to <content>
|
2012-05-29 13:32:29 +02:00
|
|
|
|
2012-08-08 00:11:36 +02:00
|
|
|
Note that these commands are available in interactive command mode, but are
|
|
|
|
not that useful in this context.
|
2012-09-11 13:54:43 +02:00
|
|
|
|
|
|
|
FIFO Buffer
|
|
|
|
-----------
|
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
the +edit+ command can take a -fifo parameter:
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
-----------------------------------
|
2012-09-11 13:54:43 +02:00
|
|
|
:edit -fifo <filename> <buffername>
|
2012-09-12 19:28:38 +02:00
|
|
|
-----------------------------------
|
2013-01-03 18:57:30 +01:00
|
|
|
|
2012-09-12 19:28:38 +02:00
|
|
|
in this case, a buffer named +<buffername>+ is created which reads its content
|
2012-09-12 19:54:46 +02:00
|
|
|
from fifo +<filename>+. When the fifo is written to, the buffer is automatically
|
2012-09-11 13:54:43 +02:00
|
|
|
updated.
|
2012-09-12 19:54:46 +02:00
|
|
|
|
2012-09-11 13:54:43 +02:00
|
|
|
This is very useful for running some commands asynchronously while displaying
|
|
|
|
their result in a buffer. See rc/make.kak and rc/grep.kak for examples.
|
2012-09-12 14:21:08 +02:00
|
|
|
|
2012-09-12 19:54:46 +02:00
|
|
|
When the buffer is deleted, the fifo will be closed, so any program writing
|
|
|
|
to it will receive SIGPIPE. This is usefull as it permits to stop the writing
|
|
|
|
program when the buffer is deleted.
|
|
|
|
|
2012-11-09 18:30:24 +01:00
|
|
|
Menus
|
|
|
|
-----
|
|
|
|
|
|
|
|
When a menu is displayed, you can use *j*, *control-n* or *tab* to select the next
|
|
|
|
entry, and *k*, *control-p* or *shift-tab* to select the previous one.
|
|
|
|
|
|
|
|
Using the */* key, you can enter some regex in order to restrict available choices
|
|
|
|
to the matching ones.
|
|
|
|
|
2012-09-12 14:21:08 +02:00
|
|
|
Kakrc
|
|
|
|
-----
|
|
|
|
|
|
|
|
The kakrc file next to the kak binary (in the src directory for the moment)
|
|
|
|
is a list of kak commands to be executed at startup.
|
|
|
|
|
|
|
|
The current behaviour is to execute local user commands in the file
|
2012-09-12 19:28:38 +02:00
|
|
|
$HOME/.config/kak/kakrc and in all files in $HOME/.config/kak/autoload
|
|
|
|
directory
|
2012-09-12 14:21:08 +02:00
|
|
|
|
|
|
|
Place links to the files in src/rc/ in your autoload directory in order to
|
|
|
|
execute them on startup, or use the runtime command (which sources relative
|
|
|
|
to the kak binary) to load them on demand.
|
|
|
|
|
|
|
|
Existing commands files are:
|
2012-09-12 19:28:38 +02:00
|
|
|
|
2012-09-12 14:21:08 +02:00
|
|
|
* *rc/kakrc.kak*: provides kak commands files autodetection and highlighting
|
2012-09-12 19:28:38 +02:00
|
|
|
* *rc/cpp.kak*: provides c/c++ files autodetection and highlighting and the +alt+
|
2012-09-12 14:21:08 +02:00
|
|
|
command for switching from c/cpp file to h/hpp one.
|
|
|
|
* *rc/asciidoc.kak*: provides asciidoc files autodetection and highlighting
|
|
|
|
* *rc/diff.kak*: provides patches/diff files autodetection and highlighting
|
|
|
|
* *rc/git.kak*: provides various git format highlighting (commit message editing,
|
|
|
|
interactive rebase)
|
2012-09-12 19:28:38 +02:00
|
|
|
* *rc/make.kak*: provides the +make+ and +errjump+ commands along with highlighting
|
2012-09-12 14:21:08 +02:00
|
|
|
for compiler output.
|
2012-09-12 19:28:38 +02:00
|
|
|
* *rc/grep.kak*: provides the +grep+ and +gjump+ commands along with highlighting
|
2012-09-12 14:21:08 +02:00
|
|
|
for grep output.
|
2012-09-12 19:28:38 +02:00
|
|
|
* *rc/global.kak*: provides the +tag+ command to jump on a tag definition using
|
2012-09-12 14:21:08 +02:00
|
|
|
gnu global tagging system.
|
2012-11-09 18:30:24 +01:00
|
|
|
* *rc/ctags.kak*: provides the +tag+ command to jump on a tag definition using
|
|
|
|
exuberant ctags files, this script requires the *readtags* binary, available
|
|
|
|
in the exuberant ctags package but not installed by default.
|
2012-12-26 17:52:17 +01:00
|
|
|
* *rc/client.kak*: provides the +new+ command to launch a new client on the current
|
|
|
|
session, if tmux is detected, launch the client in a new tmux split, else
|
|
|
|
launch in a new terminal emulator.
|
2013-03-15 00:52:07 +01:00
|
|
|
* *rc/clang.kak*: provides the +clang-enable-autocomplete+ command for C/C++
|
|
|
|
insert mode completion support. This needs uses clang++ compiler.
|
2012-12-26 17:52:17 +01:00
|
|
|
|
|
|
|
Certain command files defines options, such as grepcmd (for :grep) or
|
|
|
|
termcmd (for :new).
|