TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I remember some time ago I always used a shortcut in VIM that allowed me to type this (<X> is indication of the location of the cursor):

... rest of document ...

  some text
  more text

... document continues ....

and then I would key in some shortcut at the location of <X> and the matching \end{<ENVIRONMENT>} would be inserted:

... rest of document ...

  some text
  more text

... document continues ....

Here, of course, <ENVIRONMENT> can be anything, like align or itemize.

I know about VIM's <C-x> + <C-p>, <C-x + <C-n> and <C-x> + <C-o>. The last one works very well for closing HTML tags, but it doesn't work in LaTeX.

I forgot what it was and I hope someone here knows it. It might have been a plugin but I don't think so. If anyone can tell me what it is, I will be forever grateful.

EDIT: Of course I am using LaTeX-Suite (or vim-latex, wish they'd stick to a name).

share|improve this question
I'm not referring to that, but nice to know, it's basically as useful as what I'm looking for, thank you! – pancake Jul 4 '12 at 19:04
Perhaps you are thinking of the closeb script. – Aditya Jul 4 '12 at 22:17
Tested the closeb script, works very well. – Rmano Feb 4 '14 at 0:22

Something that is pretty much as useful is to type nameofenvironment then F5 which gives



and puts the cursor in the body of the environment. You can leave the environment easily by pressing CTRL J

share|improve this answer

When using VimTeX, you can type ]] in insert mode to close the current environment.

share|improve this answer

You search for the closeb plugin. It does exactly what you describe.

If you enable it and press Ctrl+_ in insert mode, it closes the current environment.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.