mstaal
mstaal

Reputation: 630

Vim-LaTeX - How to auto close brackets and how to compile using vim-commands

I would like to know how to close brackets like (), {} and [] by only typing (, { or [ once when using Vim-LaTeX. I would also like to know how to do it in a way so that my cursor ends inside a bracket after vim closes the bracket. As of now I try to write the following in my .vimrc-file, but it does not work in .tex-files:

inoremap { {}<Left>
inoremap {{ {
inoremap {} {}<Left>

inoremap ( ()<Left>
inoremap (( (
inoremap () ()<Left>

inoremap [ []<Left>
inoremap [[ [
inoremap [] []<Left>

Is there anyone who knows how to solve this? Another question: Right now I compile LaTeX-files in Vim-LaTeX by pressing \ll but is there a way to do it using a vim-command? Like

:CompileSomething

Upvotes: 2

Views: 1592

Answers (2)

Luc Hermitte
Luc Hermitte

Reputation: 32956

vim-latex uses a specific pattern to defines mappings: it relies on the plugin named IMAP (or IMAPS?). If you want to define mappings while IMAP is around, you'd better use its functions. Otherwise you'll likely observe odd behaviours.

Regarding bracketing systems and compatibility with IMAP, my lh-brackets detects if IMAP is installed before defining its mappings in order to define compatible mappings. Opening brackets characters (let say () will trigger the insertion of the related pair + a placeholder (like with vim-latex) + the cursor moved in the right place (-> (<cursor>)<+placeholder+>). And hitting the closing bracket key will jump to the placeholder (and thus close the brackets pair) if the cursor is just before the closing bracket characters. However I'm not sure this is exactly what you are looking for.
Though, context can be analysed to tune the exact behaviour. See the markdown bracket mappings for instance.

EDIT: Regarding the command, you can always roll up your own with (untested)

command -nargs=0 CompileLaTeX :exe "normal \\ll"

Upvotes: 1

Oni1
Oni1

Reputation: 1505

  1. Question.

    you can modify your .vimrc file with this statement:

:inoremap ( ()<Esc>i

Here is a clearer explanation: Autobrackets

EDIT: Did you done this things in your .vimrc file? Correct Settings for VIM Latex

Upvotes: 0

Related Questions