# Wrapping text in environment vimtex

I use vimtex although I am by no means an expert in Vim, so it may be that I'm missing something obvious. Anyway, I am looking for functionality similar to that of 'cse, csc, csd' (which change the surrounding environment, command, or delimiter respectively) where instead of changing something I would like to add an environment, command, or delimiter around some text highlighted in say visual mode.

The place I find myself most often needing this is when I quickly import a graphic and then have to go back and wrap the command in a center environment. This also sometimes comes up when I have a variable say t which I've forgotten to drop in math mode (so it appears as a non-math t). It's a pain to do insert mode -> $-> exit insert mode -> l -> insert mode ->$' and I'm sure there is an easier way, but I haven't been able to find it.

There were a couple of good suggestions on a post I made at the LaTeX stack exchange, but was told to come here for something more official.

• VimTeX does not really have this built in, except for the <plug>(vimtex-cmd-create) mapping (default mapped to F7) which works similar to what you ask for for commands. I believe plugins like surround.vim or vim-sandwich and snippet plugins like UltiSnips are better tools for this feature. Aug 1 at 11:25
• Hi Karl, thanks for the input! I indeed have had good luck with using surround as suggested. Also, I'm sure you get this a lot, but thanks so much for keeping vimtex updated! Aug 1 at 23:17
• Thanks for using it :) Aug 3 at 6:53

• ys<TARGET>l or ys<TARGET>l will prompt for a \begin{ environment
• ys<TARGET>\$ will surround with dollar-signs
You can also use S in visual mode, along with other keys as shown in :help surround`.