Kakoune-mark is simple but profoundly useful

Per the plugin page:

Mark is an extension to the kakoune editor that allows highlighting all occurrences of one or several words in different colors.

Yes. It’s a more powerful alternative to this snippet which can be found in mawww’s kakrc itself:

# Highlight the word under the cursor
# ───────────────────────────────────

declare-option -hidden regex curword
set-face global CurWord default,rgb:4a4a4a

hook global NormalIdle .* %{
    eval -draft %{ try %{
        exec <space><a-i>w <a-k>\A\w+\z<ret>
        set-option buffer curword "\b\Q%val{selection}\E\b"
    } catch %{
        set-option buffer curword ''
    } }
add-highlighter global/ dynregex '%opt{curword}' 0:CurWord

It mimics what can be found in a few other editors.
Some may find this snippet more distractive in rare cases, but if the highlight color is subtle enough it’s not that intrusive.

Wow, I gotta go through mawww’s kakrc. Looks like some gems are in there.

I like this snippet, but I’m not sure what’s the purpose of the <a-k>\A\w+\z<ret>.
<a-i>w should already select entire words (and fail if not on one), and it has the advantage of respecting extra_word_chars, unlike \w.

This plugin is super useful, also note that you can mark custom pattern with

mark-pattern set 'regex'

I use it all the time :slight_smile:

I think you are right, it can be removed now, because w will fail if it did not select a word, preventing the following commands from executing. I think I wrote it like that at a time where if the cursor was not on a word character, w would just do nothing.