lervag / vimtex

VimTeX: A modern Vim and neovim filetype plugin for LaTeX files.
MIT License
5.42k stars 389 forks source link

How to add delimiters list for big and bigg #846

Closed vanabel closed 7 years ago

vanabel commented 7 years ago

We know that vimtex has tsd to toggle of ( and ) between \left( and \right) and so on. I have read the related section g:vimtex_delim_list but still stacked at how to add gtsd to toggle ( and ) between \big( and \big) and ggtsd to toggle ( and ) between \bigg( and \bigg).

Idealy hope this work also for other delimiters like {...} and [...].

I need this mainly because that in the following example of TeX, the \left...\right is not work:

\begin{align*}
0&=\left(\text{first line of formula}\\
  &\qquad\text{the second line of formula}\right)
\end{align*}
lervag commented 7 years ago

First, \big(...\big) and similar are not really best practice. You should use \bigl(...\bigr). This also makes it possible for vimtex to parse. I'll write a more thorough reply later.

lervag commented 7 years ago

Ok, so: You want to add two new maps, gtsd and ggtsd. However, there is no "simple" way to do this from vimtex today. However, you can set

    let g:vimtex_delim_toggle_mod_list = [
      \ ['\left', '\right'],
      \ ['\bigl', '\bigr'],
      \ ['\biggl', '\biggr'],
      \]

In order for tsd to toggle between the above modifier variants. With the above setting, this also works for you example TeX input.

vanabel commented 7 years ago

That is a really great solution!

lervag commented 7 years ago

I'm happy you like it :)

bellecp commented 4 years ago

With the above g:vimtex_delim_toggle_mod_list code by @lervag, one can go directly

Such a great solution/plugin, thanks again for your time on this

lervag commented 4 years ago

Such a great solution/plugin, thanks again for your time on this

Happy you like it! :)