Vim-latex

From miki
Jump to navigation Jump to search

General

Configuration

  • To select pdf as default compile format, add to file .vim/ftplugin/tex.vim:
" Set default compile target type as 'pdf'
let g:Tex_DefaultTargetFormat = 'pdf'

Mappings

Plugin - vim-latex

^m
F5
S-F5
F7
S-F7
EEQ ,eq
FSF `sf
A-l
A-b
A-c
A-o
F6 \rf

Jump to next
Insert/expand/enclose in environment
Change environment
Insert/expand/enclose in command
Change command
Insert / enclose in equation
Insert / enclose in font \textsf{}
Expand ([|{<q or label
Enclose in \\mathbf{}
\\mathcal{} or \\cite{}
Insert \\item{} (was A-i)
Refresh folds

Troubleshooting

  • Use A-o to insert \item\ instead of A-i, because the latter collides with roman letter é. Also remap A-o such that it also works in the console (^[o is obtained via C-v Esc C-o):
--- a/.vim/ftplugin/latex-suite/envmacros.vim
+++ b/.vim/ftplugin/latex-suite/envmacros.vim
-               imap <buffer> <M-i> <Plug>Tex_InsertItemOnThisLine
+               imap <buffer> <M-o> <Plug>Tex_InsertItemOnThisLine
+               set <M-o>=^[o
  • My .vimrc configuration:
"############################################################################################################
" VIM-LATEX
"############################################################################################################

" REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.
filetype plugin on

" IMPORTANT: win32 users will need to have 'shellslash' set so that latex
" can be called correctly.
" set shellslash

" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name.
set grepprg=grep\ -nH\ $*

" OPTIONAL: This enables automatic indentation as you type.
filetype indent on

" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'

" Use <C-l> for jump formward instead of <C-J>
imap <C-l> <Plug>IMAP_JumpForward
nmap <C-l> <Plug>IMAP_JumpForward
vmap <C-l> <Plug>IMAP_JumpForward
  • To have a LaTeX file compile with XeLaTeX automatically:
:let g:Tex_CompileRule_pdf = 'xelatex -interaction=nonstopmode '
  • In multiple file setup, touch file main.tex.latexmain to indicate vim-latex that main.tex is the main file and should always compile this file, independently of what file is currently edited. See also variable Tex_MainFileExpression (see manual):
let g:Tex_MainFileExpression = 'MainFile(modifier)'
  • vim-latex creates automatically new folds for every itemize / enumeration / description blocks. This considerably slows down or blocks opening of beamer presentation that usually contains a lot of these blocks. Here a patch to disable this.
--- a/.vim/ftplugin/latex-suite/folding.vim
+++ b/.vim/ftplugin/latex-suite/folding.vim
@@ -237,16 +237,16 @@ function! MakeTexFolds(force)
        " }}}
 
        " {{{ items
-       if g:Tex_FoldedMisc =~ '\<item\>'
-               call AddSyntaxFoldItem (
-                       \ '^\s*\\item',
-                       \ '^\s*\\item\|^\s*\\end{\(enumerate\|itemize\|description\)}',
-                       \ 0,
-                       \ -1,
-                       \ '^\s*\\begin{\(enumerate\|itemize\|description\)}',
-                       \ '^\s*\\end{\(enumerate\|itemize\|description\)}'
-                       \ )
-       endif
+       " if g:Tex_FoldedMisc =~ '\<item\>'
+       "       call AddSyntaxFoldItem (
+       "               \ '^\s*\\item',
+       "               \ '^\s*\\item\|^\s*\\end{\(enumerate\|itemize\|description\)}',
+       "               \ 0,
+       "               \ -1,
+       "               \ '^\s*\\begin{\(enumerate\|itemize\|description\)}',
+       "               \ '^\s*\\end{\(enumerate\|itemize\|description\)}'
+       "               \ )
+       " endif
        " }}}
 
        " {{{ title

Keyboard and shortcuts

command description
o keyword F5 Insert environment keyword
amsmathF5
i EFL Insert environment flushleft Expand the 3-letter sequence EFL. Equivalent to i flushleft F5
v select text ,fl Enclose selected text in environment flushleft.
S-F5 Change enclosing environment
F7 Insert command
S-F7 Change enclosing command
\ll Compile
\lv View compiled file
command description
(insert mode) C-u Go to next placeholder
amsmathF5sumlimits,C-u
(insert mode, eqn context) ^^ Quick exponent (template e^{}<++>)
eqnarrayF5e^^j
(insert mode, eqn context) __ Quick subscript (template e_{}<++>
eqnarrayF5a__i
Auc-Tex Key Binding description
`p \pi
`8 \infty
`/ \frac
`% \frac
`0 ^\circ