---
name: "kak_expansions"
section: "1"
platform: "linux"
package: "kakoune"
version: "0~2016.12.20.1.3a6167ae-1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/kak_expansions"
---

# kak\_expansions(1)

a

## NAME

expansions - a

## STRINGS

'strings'

uninterpreted strings, use a backslash (\\') to escape the separator

"strings"

expanded strings, % strings (c.f. next section) contained are expended, use a backslash (\\\\%) to escape the separator

%{strings}

these strings are very useful when entering commands

• the *{* and *}* delimiters are configurable, you can use any non alphanumeric character

```
e.g. %[string], %<string>, %(string), %~string~, %!string!
```

• if the character following *%* is one of *{\[(\<*, then the closing one is the matching *}\])\>* and the delimiters are not escapable but are nestable

```
e.g. %{ roger {}; } is a valid string, %{ marcel \} as well
```

## TYPED EXPANSIONS

**sh**

shell expansion, similar to posix shell *$(...)* construct (c.f. next section)

**reg**

register expansion, will be replaced by the content of the given register

**opt**

option expansion, will be replaced with the value of the given option

**val**

value expansion, gives access to the environment variable available to the Shell expansion. The *kak\_* prefix is not used there

**arg**

argument expansion, gives access to the arguments of the current command, the content can be a number, or @ for all arguments

## SHELL EXPANSIONS

The *%sh{...}* expansion replaces its content with the output of the shell commands in it. The following environment variables are used to pass information about Kakoune’s state:

**kak\_selection**

content of the main selection

**kak\_selections**

content of the selection separated by colons, colons in the selection contents are escaped with a backslash

**kak\_selection\_desc**

range of the main selection, represented as anchor,cursor; anchor and cursor are in this format: line.column

**kak\_selections\_desc**

range of the selections separated by colons

**kak\_bufname**

name of the current buffer

**kak\_buffile**

full path of the file or same as kak\_bufname when there’s no associated file

**kak\_buflist**

the current buffer list, each buffer separated by a colon

**kak\_timestamp**

timestamp of the current buffer, the timestamp is an integer value which is incremented each time the buffer is modified

**kak\_runtime**

directory containing the kak binary

**kak\_count**

count parameter passed to the command

**kak\_opt\_\<name\>**

value of option **name**

**kak\_reg\_\<r\>**

value of register **r**

**kak\_socket**

filename of session socket (*/tmp/kak-\<session\>*)

**kak\_session**

name of the current session

**kak\_client**

name of current client

**kak\_cursor\_line**

line of the end of the main selection

**kak\_cursor\_column**

column of the end of the main selection (in byte)

**kak\_cursor\_char\_column**

column of the end of the main selection (in character)

**kak\_window\_width**

width of the current kakoune window

**kak\_window\_height**

height of the current kakoune window

**kak\_hook\_param**

filtering text passed to the currently executing hook

**kak\_client\_env\_\<name\>**

value of the **name** variable in the client environment (e.g. **$kak\_client\_env\_SHELL** is the SHELL variable)

Note that in order for Kakoune to pass a value in the environment, the variable has to be spelled out within the body of the expansion

## MARKUP STRINGS

In certain contexts, Kakoune can take a markup string, which is a string syntax will enable the face facename until another face gets activated, or the end of the string is reached.

Literal *{* characters shall be written *{*, and a literal backslash (*\\*) that precedes a *{* character shall be escaped as well (*\\\\*).
