-
Notifications
You must be signed in to change notification settings - Fork 719
Highlighters
Syntax highlighting is supported through highlighters. You may add your own Syntax definitions in the rc
directory. There is a syntax highlighting section in the highlighters.asciidoc file.
# same ideas apply to `line`
addhl column 4 red # all chars in column 4 will be have a red color
addhl column 5 red,blue+b # all chars in column 5 will be red on blue and in bold
addhl column 6 PrimaryCursor # all chars in column 6 will be the same face than `PrimaryCursor` (see below)
decl range-specs foo '1:3.1,3.4|red' # declare an option called foo, of type range-specs
addhl ranges foo # use this option as the parameter
set buffer foo '2:3.1,3.10|blue' # update the option to trigger changes
Highlight on yank
, delete
, change
and paste
commands.
The highlight disappears at the next command.
The highlighting gives useful visual feedback for what your operation actually changed in the buffer.
face volatile +bi
hook global NormalKey [ydcpP] %{ try %{
add-highlighter dynregex \Q%reg{"}\E 0:volatile
}}
hook global NormalKey [^ydcpP] %{ try %{
remove-highlighter dynregex_\Q%reg{"}\E
}}
First add a search
face. Here, it will emphasis the searched word in bold and italic without changing the foreground or background colors:
face search +bi
Then enable search highlighting. Dynregex is plugged on the content of the search register /
:
add-highlighter dynregex '%reg{/}' 0:search
Enable search highlighting in context of search.
hook global NormalKey [/?*nN]|<a-[/?*nN]> %{ try %{
add-highlighter dynregex '%reg{/}' 0:search
}}
hook global NormalKey <esc> %{ try %{
remove-highlighter dynregex_%reg{<slash>}
}}
Now you can press Escape
to disable search highlighting.
Search highlighting is re-enabled when you are searching.
Faces can be taken from the colorscheme
files, which is what is usually done, or directly from the the list of default faces:
Name, Foreground, Background
- Default, Default, Default,
- PrimarySelection, White, Blue,
- SecondarySelection, Black, Blue,
- PrimaryCursor, Black, White,
- SecondaryCursor, Black, White,
- LineNumbers, Default, Default,
- LineNumberCursor, Default, Default, Reverse,
- MenuForeground, White, Blue,
- MenuBackground, Blue, White,
- MenuInfo, Cyan, Default,
- Information, Black, Yellow,
- Error, Black, Red,
- StatusLine, Cyan, Default,
- StatusLineMode, Yellow, Default,
- StatusLineInfo, Blue, Default,
- StatusLineValue, Green, Default,
- StatusCursor, Black, Cyan,
- Prompt, Yellow, Default,
- MatchingChar, Default, Default, Bold,
- BufferPadding, Blue, Default,
- Whitespace, Default, Default,
- Normal mode commands
- Avoid the escape key
- Implementing user mode (Leader key)
- Kakoune explain
- Kakoune TV