= Options == Description Kakoune can store named and typed values that can be used both to customize the core editor behaviour, and to store data used by extension scripts. [[set-option]] Options can be modified using the `set-option` command: -------------------------------------------- set-option [-add|-remove] ... -------------------------------------------- can be *global*, *buffer*, *window* or *current* (See <>). *current* relates to the narrowest scope in which the option is already set. When the option is a list or a map, multiple can be given as separate arguments, or can be omitted altogether in order to empty the option. If `-add` or `-remove` is specified, the new value is respectively *added* to or *removed* from the current one instead of replacing it (the exact outcome depends on the type, see below). [[unset-option]] Option values can be unset in a specific scope with the `unset-option` command: --------------------------- unset-option --------------------------- Unsetting an option will make it fallback to the value of its parent scope, hence options cannot be unset from the *global* scope. [[declare-option]] New options can be declared using the `declare-option` command: --------------------------------------------------- declare-option [-hidden] [...] --------------------------------------------------- If `-hidden` is specified, the option will not be displayed in completion suggestions. [[update-option]] Certain option type can be *updated*, usually to match potential changes in the buffer they relate to. This can be triggered by the `update-option` command: ---------------------------- update-option ---------------------------- == Types All options have a type, which defines how they are translated to/from text and their set of valid values. Some types are usable for user defined options while some other types are exclusively available to built-in options. *int*:: an integer number. `set -add` performs a math addition. + `set -remove` performs a math substraction. + *bool*:: a boolean value, yes/true or no/false *str*:: a string, some freeform text *regex*:: as a string but the set commands will complain if the entered text is not a valid regex *coord*:: a line, column pair (separated by a comma) Cannot be used with `declare-option` *-list*:: a list, elements are specified as separate arguments to the command. `set -add` appends the new element to the list. + `set -remove` removes each given element from the list. + Only `int-list` and `str-list` options can be created with `declare-option`. *range-specs*:: a timestamp (like `%val{timestamp}`, see <>) followed by a list of range descriptors. Each range descriptor must use the syntax `a.b,c.d|string` or `a.b+length|string`, with: * _a_ is the line containing the first character * _b_ is the number of bytes from the start of the line to the first byte of the first character * _c_ is the line containing the last character * _d_ is the number of bytes from the start of the line to the first byte of the last character * _length_ is the length of the range in bytes, if 0 the range is empty, but still valid. * _string_ is an arbitrary string which is associated with the range. Any `|` or `\` characters must be escaped as `\|` or `\\`. All numeric fields are 1-based. When the command `update-option` is used on an option of this type, its ranges get updated according to all the buffer modifications that happened since its timestamp. `set -add` appends the new pairs to the list. + `set -remove` removes the given pairs from the list. + See <>) *line-specs*:: a list of a line number and a corresponding flag (`|`), except for the first element which is just the timestamp of the buffer. When `update-option` is used on an option of this type, its lines get updated according to all the buffer modifications that happened since its timestamp. See <>) `set -add` appends the new specs to the list. + `set -remove` removes the given specs from the list. + Any `|` or `\` characters that occur within `` must be escaped as `\|` or `\\`. *completions*:: a list of `|`, or `` fields should be escaped as `\|` or `\\`. Options of this type are are meant to be added to the `completers` option to provide insert mode completion. Candidates are shown if the text typed by the user (between `.` and the cursor) is a subsequence of ``. For each remaining candidate, the completion menu displays ``, followed by ``, which is a Markup string (see <>). As the user selects items from the completion menu, the text they typed will be replaced with ``, and the Kakoune command in `