[Tex/LaTex] how to enclose selection in {} using vim-latex keyboard shortcuts

keyboardvim

Is there an easy way of wrapping a selected text in {} with a shortcut in the same way you can turn a text into italics by typing `it while selecting a piece of text.

I tried `{ but and that works but formatting the {}'s as for text not commands

e.g to transform "Computational Skills Learned:"

what happens is:

\left\{ Computational Skills Learned: \right\}

This is not what I want, I want

{Computational Skills Learned:}

Best Answer

As morbusg mentioned, the surround plugin is the way to go.

You select the text eg. using visual mode, then you press S and the closing brace }. You can use any character with a matching partner: ], >, ), etc. If you use the left part of the pair, it additionally surrounds the selected text with a space. Example:

Computational Skills Learned:

Assuming the cursor is on the “C” in “Computational”, then you press vf:S} and you get this result:

{Computational Skills Learned:}

If you press vf:S[ the result is:

[ Computational Skills Learned: ]

Note: In older versions the small s was used, but it has been changed in favour of the capital S.