Install and configure vim-latex

Source: Internet
Author: User
Tags imap

As we get used to Vim's lightness and do not want to install the extra Tex Editor, we configure Vim according to our usage habits.

1. Install the vim-latex plug-in

  • : Http://sourceforge.net/projects/vim-latex/files/
  • DownloadVim-latex-1.8.23-20120125.768-git8b62284.tar.gzDecompress the package directly ~ /. Vim

2 Vim Configuration

(1) latex-related configuration in vimrc

  1. 405 "Vim latex suite

  2. 406 "http://vim-latex.sourceforge.net/index.php? Subject = download & Title = download
  3. 407 "make grep always generate file name
  4. 408 set grepprg = grep \-NH \ $ *
  5. 409 "Vim sets the empty Tex file to plaintex instead of Tex by default, so that latex-suite is not loaded.
  6. 410 Let G: tex_flavor = 'latex'
  7. 411 set iskeyword + =:
  8. 412 autocmd bufenter *. Tex set Sw = 2
  9. 413

(2) Modify ~ /. Vim/ftplugin/latex-Suite/texrc to compile the Tex file using xelatex and preview the PDF using evince

  1. 86 If has ('macunix ')
  2. 87 texlet G: tex_defaulttargetformat
    = 'Pdf'
  3. 88 else
  4. 89 texlet G: tex_defaulttargetformat
    = 'Pdf '/* all generate PDF */
  5. 90 endif
  1. 115 texlet G: tex_compilerule_pdf
    = 'Xelatex-interaction = nonstopmode $ * '/* compile with xelatex */

  1. 145 texlet G: tex_viewrule_pdf
    = 'Evince '/* use evince to preview the generated PDF */

3. Tips for using vim-latex

(1) Common shortcut keys
CTRL-J, F5, F7, F9, Shift-F5, Shift-F7,/LL (compile shortcut),/LV (view PDF shortcut),/LS, CTRL-x Ctrl-K (supplemented by dictionary.

(2) Write/CITE {and press F9 without a cross reference. The reason is that the python interface in VIM has some problems with latex-suite. disable it.
You only need ~ /. Vim/ftplugin/latex-Suite/texrc is enabled by default ~ /. Vim/ftplugin/latex-Suite/texrc, Set

Texlet G: tex_usepython = 1

Change

Texlet G: tex_usepython = 0

That's it!

(3) In order to be able to perform a forward search, set the parameters and use/ll for compilation. However, when makefile is available in the working directory,/ll does not execute the set compilation command, but executes makefile, as a result, forward search cannot be performed.
You only need to disable makefile ~ /. Vim/ftplugin/latex-Suite/texrc

Texlet G: tex_usemakefile = 0 (4) set forward search, in ~ /. Specify Let G: tex_compilerule_dvi = 'latex-Src-specials-interaction = nonstopmode $ * 'in vimrc *'

Note: You should also set tctarget DVI. However, if you do not set tctarget DVI, running VI in the above file will prompt an error, but you can execute this command in VI, no matter whether it can be used. After the settings are completed, you need to re-compile the Tex file (use/LL), and then/ls can be searched and previewed.

(5) For convenience, I also made some settings, including shortcut keys, in ~ In/. Vim/ftplugin/tex. VIM:

Map <F4> <ESC>: q <CR> "F4 close the window (buffer)
Map <F2> <ESC>: W <CR>/ll "F2 save and compile
Imap <F2> <ESC>: W <CR>/LL
Map <F3> <ESC>/LV "F3 View
Imap <F3> <ESC>/LV
NMAP <tab> <c-j> "uses the tab key instead of Ctrl-J to redirect.
Imap <tab> <c-j>
Vmap <tab> <c-j>
Set keywordprg =: Help "press the K key to find help for words at the cursor. The default value is man.
Cmap XXX! Make
Set iskeyword + = ., _ "facilitates fig. XX, prl1038512345 and other forms of search completion, otherwise by default, fig is not set. XX is regarded as a word, but as fig and XX. "is used as the separator of the word.
(6) temporarily cancel the definition of the shortcut key. For example, if you want to enter double quotation marks, it will automatically become ''when you press ''.
So how can we disable automatic replacement and directly output?
Remember <Ctrl-V>!
<Ctrl-V> "get"
SS <Ctrl-V> S to get SSS
~ <Ctrl-V> ~ Get ~~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.