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.

2
  • After some update, it is invalid now. The block [...] would not indent for now. Could you provide some new suggestions? Thank you!
    – jiaopjie
    Commented May 14 at 9:10
  • I can't think of anything that should have changed here. It's not easy to provide a new suggestion when I still think the current one should work. If it doesn't work. then please open an issue on the github repo. To be clear: I suspect there may be a problem in your configuration. Commented May 15 at 14:54

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.