= Commands Some commands take an exclamation mark (*!*), which can be used to force the execution of the command (i.e. to quit a modified buffer, the command *q!* has to be used). Aliases are mentionned below each commands. *doc* :: *alias* help + display documentation about a topic. The completion list displays the available topics == Files and Buffers *change-directory* []:: *alias* cd + change the current directory to *directory*, or the home directory if unspecified *edit[!]* [ []]:: *alias* e + 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 *write[!]* []:: *alias* w + write buffer to or use its name if filename is not given. If the file is write-protected, its permissions are temporarily changed to allow saving the buffer and restored afterwards when the write! command is used. *write-all*:: *alias* wa + write all buffers that are associated to a file *quit!* []:: *alias* q + exit Kakoune, use quit! to force quitting even if there is some unsaved buffers remaining. If specified, the client exit status will be set to *write-all-quit* []:: *alias* waq + write all buffers and quit. If specified, the client exit status will be set to *buffer* :: *alias* b + switch to buffer *buffer-next*:: *alias* bn + switch to the next buffer *buffer-prev*:: *alias* bp + switch to the previous buffer *delete-buffer[!]* []:: *alias* db + delete the buffer *rename-buffer* :: set current buffer name *source* :: execute commands in == Clients and Sessions *rename-client* :: *alias* nc + set current client name *rename-session* :: set current session name *kill[!]*:: terminate the current session, all the clients as well as the server == Options *declare-option* [-hidden] []:: *alias* decl + declare a new option, the -hidden hides the option in completion suggestions (See <>) *set-option* :: *alias* set + change the value of an option note that the name of a particular buffer can be specified when the target *scope* is 'buffer', e.g. set buffer=/path/to/buffer foo "bar"; the scope can also take the `current` special value, which will automatically point to the narrowest scope available in the current context (See <>) *unset-option* :: *alias* unset + unset the value of an option (See <>) *update-option* :: update the value of an option if its type supports that operation (See <>) == Commands and Keys *define-command* [] :: *alias* def + define a new command (See <>) *alias* :: define a new alias, within the context of a scope *unalias* []:: remove an alias if its current value is the same as the one passed as an optional parameter, remove it unconditionally otherwise *evaluate-commands* [] ...:: *alias* eval + evaluate commands, as if they were entered in the command prompt (See <>) *execute-keys* [] ...:: *alias* exec + execute a series of keys, as if they were hit (See <>) *map* :: bind a list of keys to a combination (See <>) *unmap* []:: unbind a key combination (See <>) *declare-user-mode* :: declare a new user keymap mode within the context of a scope *enter-user-mode* :: enable keymap mode for next key == Hooks *hook* [-group ] :: execute a command whenever an event is triggered (See <>) *remove-hooks* :: *alias* rmhooks + remove every hooks in *scope* that are part of the given *group* (See <>) == Display *echo* [options] :: show *text* in status line, with the following *options*: *-markup*::: expand the markup strings in *text* (See <>) *-debug*::: print the given text to the *\*debug** buffer *set-face* :: *alias* face + define a face (See <>) *colorscheme* :: load named colorscheme *add-highlighter* [] ...:: *alias* addhl + add a highlighter to the current window (See <>) *remove-highlighter* :: *alias* rmhl + remove the highlighter whose id is *highlighter_id* (See <>) == Helpers Kakoune provides some helper commands that can be used to define composite commands in scripts. They are also available in the interactive mode, but not really useful in that context. *prompt* :: prompt the user for a string, when the user validates, executes the command. The entered text is available in the `text` value accessible through `$kak_text` in shells or `%val{text}` in commands. The *-init * switch allows setting initial content, the *-password* switch hides the entered text and clears the register after command execution. The *-on-change* and *-on-abort* switches, followed by a command will have this command executed whenever the prompt content changes or the prompt is aborted, respectively. *on-key* :: wait for next key from user, then execute , the key is available through the `key` value, accessible through `$kak_key` in shells, or `%val{key}` in commands. *menu* ...:: display a menu using labels, the selected label’s commands are executed. The *menu* command can take an *-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) *info* [options] :: display text in an information box with the following *options*: *-anchor* .::: print the text at the given coordinates *-placement* {above,below}::: set the placement relative to the anchor *-title* ::: set the title of the message box *try* catch :: prevent an error in *commands* from aborting the whole command execution, execute *on_error_commands* instead. If nothing is to be done on error, the catch part can be omitted *nop*:: does nothing, but arguments will be evaluated (e.g. shell expansion) *fail* :: raise an error, uses as its description *set-register* :: *alias* reg + set register *name* to *content* (See <>) *select* .,.:...:: replace the current selections with the one described in the argument *debug* {info,buffers,options,memory,shared-strings,profile-hash-maps,faces,mappings}:: print some debug information in the *\*debug** buffer == Multiple commands Commands (c.f. previous sections) can be chained, by being separated either by new lines or by semicolons, as such a semicolon must be escaped with a backslash (\;) to be considered as a literal semicolon argument == Declaring new commands New commands can be defined using the *define-command* command: *define-command* [flags] :: *commands* is a string containing the commands to execute, and *flags* can be any combination of the following parameters: *-params* ::: the command accepts a *num* parameter, which can be either a number, or of the form .., with both and omittable *-file-completion*::: try file completion on any parameter passed to this command *-client-completion*::: try client name completion on any parameter passed to this command *-buffer-completion*::: try buffer name completion on any parameter passed to this command *-command-completion*::: try command completion on any parameter passed to this command *-shell-completion*::: following string is a shell command which takes parameters as positional params and output one completion candidate per line. The provided shell command will run after each keypress during the executing of the shell command, the following env vars are available: - *kak_token_to_complete*:::: Index of the token being completed in the command line. - *kak_pos_in_token*:::: Position of the cursor inside the token being completed, in bytes from token start. *-shell-candidates*::: following string is a shell command which takes parameters as positional params and output one completion candidate per line. The provided shell command will run once at the beginning of each completion session, candidates are cached and then used by kakoune internal fuzzy engine during the executing of the shell command, the following env vars are available: - *kak_token_to_complete*:::: Index of the token being completed in the command line. *-allow-override*::: allow the new command to replace an existing one with the same name *-hidden*::: do not show the command in command name completions *-docstring*::: define the documentation string for the command Using shell expansion allows defining complex commands or accessing Kakoune's state: -------------------------------------------------------- def " print_selection %{ echo %sh{ ${kak_selection} } }" --------------------------------------------------------