# Kakoune-mark is simple but profoundly useful

**URL:** <https://discuss.kakoune.com/t/kakoune-mark-is-simple-but-profoundly-useful/17>\
**Category:** Plugins\
**Tags:** highlighter\
**Created:** [September 12, 2018, 5:50pm UTC](https://discuss.kakoune.com/t/kakoune-mark-is-simple-but-profoundly-useful/17 "2018-09-12T17:50:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertmeta](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/robertmeta/32/833_2.png) [@robertmeta](https://discuss.kakoune.com/u/robertmeta)\
**Post date:** [September 12, 2018, 5:50pm UTC](https://discuss.kakoune.com/t/kakoune-mark-is-simple-but-profoundly-useful/17/1 "2018-09-12T17:50:19Z")

</div>

> **[fsub / kakoune-mark · GitLab](https://gitlab.com/fsub/kakoune-mark)**
>
> A kakoune plugin to highlight multiple words in different colors

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.

![](https://discuss.kakoune.com/uploads/default/original/1X/b4c5f6a6fb9f32e1c295d2cf9b557d65732663dd.gif)

---

<div class="post-metadata">

**Author:** ![Delapouite](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/delapouite/32/10_2.png) [@Delapouite](https://discuss.kakoune.com/u/Delapouite)\
**Post date:** [September 13, 2018, 6:13am UTC](https://discuss.kakoune.com/t/kakoune-mark-is-simple-but-profoundly-useful/17/2 "2018-09-13T06:13:11Z")

</div>

Yes. It’s a more powerful alternative to this snippet which can be found in [mawww’s kakrc](https://github.com/mawww/config/blob/master/kakrc#L40-L54) itself:

```auto
# 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.

---

<div class="post-metadata">

**Author:** ![robertmeta](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/robertmeta/32/833_2.png) [@robertmeta](https://discuss.kakoune.com/u/robertmeta)\
**Post date:** [September 13, 2018, 6:20am UTC](https://discuss.kakoune.com/t/kakoune-mark-is-simple-but-profoundly-useful/17/3 "2018-09-13T06:20:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![occivink](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/occivink/32/27_2.png) [@occivink](https://discuss.kakoune.com/u/occivink)\
**Post date:** [September 24, 2018, 1:20pm UTC](https://discuss.kakoune.com/t/kakoune-mark-is-simple-but-profoundly-useful/17/4 "2018-09-24T13:20:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TeddyDD](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/teddydd/32/21_2.png) [@TeddyDD](https://discuss.kakoune.com/u/TeddyDD)\
**Post date:** [September 25, 2018, 9:40am UTC](https://discuss.kakoune.com/t/kakoune-mark-is-simple-but-profoundly-useful/17/5 "2018-09-25T09:40:42Z")

</div>

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

`mark-pattern set 'regex'`

I use it all the time 🙂

---

<div class="post-metadata">

**Author:** ![mawww](https://discuss.kakoune.com/letter_avatar_proxy/v4/letter/m/4bbf92/32.png) [@mawww](https://discuss.kakoune.com/u/mawww)\
**Post date:** [September 25, 2018, 11:06pm UTC](https://discuss.kakoune.com/t/kakoune-mark-is-simple-but-profoundly-useful/17/6 "2018-09-25T23:06:47Z")

</div>

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.
