0

When setting indentation using vimtex, I meet some problem. I set the option g:vimtex_indent_delims to indent [...] blocks.

let g:vimtex_indent_delims = {
      \ 'open'  : ['{','(','['],
      \ 'close' : ['}',')',']'],
      \}

But then the \[...\] block will indent twice. What I get is the following.

\[
        f(x)
\]
[
    f(x)
]

Compared with this, there is no problem for {...} and \{...\} blocks, or (...) and \(...\) blocks.

\{
    f(x)
\}
{
    f(x)
}
\(
    f(x)
\)
(
    f(x)
)

So, is it possible to indent [...] blocks, while indent \[...\] blocks only one time?

1 Answer 1

2

You need to specify regexes that do not match on \[ and \]. This should work:

let g:vimtex_indent_delims = {
      \ 'open'  : ['{', '(', vimtex#re#not_bslash . '['],
      \ 'close' : ['}', ')', vimtex#re#not_bslash . ']'],
      \}

The vimtex#re#bslash is a regex that matches whenever the preceding atom is not a single backslash.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.