1

Suppose I have the following text

\[
    X = (a, b)
\]

I want to easily convert it to the following, including indentation:

\[
    X = (
        a, b
    )
\]

Suppose my cursor is on a. How can I do this with minimal keystrokes?

I'm doing this most often in LaTeX code using VimTeX.

2

1 Answer 1

1

With https://github.com/tpope/vim-surround, that's cSbb/cS((.

Manually, I'd go for vibc<enter><esc>[p==.


Whatever solution you like, you can create a mapping for it:

" ~/.vim/after/ftplugin/tex.vim
nnoremap <buffer> …keys… …solution here…
" adjust b:undo_ftplugin to `execute "silent! nunmap <buffer> …keys…"`

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.