Matching a specific block


#1

In Go, there is a lot of

if err != nil {
    ....
}

I want to match and highlight these blocks, I can match a simple error block with addhl window/ regex 'if err != nil \{.*?\} 0:red'

But, I want it to work with nested } chars (so – I want to go to the matching pair basically.


#2

As far as I know, the only way to match a recursive structure in Kakoune’s syntax-highlighting system is with a recursive region, and regions are a bit annoying because they’re hard boundaries for the regular regex highlighters.