Changes

Jump to navigation Jump to search
21 bytes removed ,  21:01, 30 October 2016
m
no edit summary
* Perhaps borrow something from https://github.com/lervag/vimtex or http://vim-latex.sourceforge.net/?
== A note on filetype Filetype detection ==
TeX (Plain TeX), LaTex and ConTeXt all use the <tt>.tex</tt> extension for files, which makes it difficult to detect the filetype based on the extension. From Vim 7 onwards, Vim does some intelligent checking to see it the file is <tt>plaintex</tt> or <tt>latex</tt> or <tt>context</tt>.
so the next time you open a <tt>*.tex</tt> file, Vim will always recognize it as a ConTeXt document.
== A note on spell Spell checking ==
Vim 7 or later has a built-in spell checker. To enable it or disable it, use:
download the language data into your <tt>.vim</tt> folder, if such language is not available.
You can put the above settings in your <tt>.vimrc</tt> if you like.
 
== Powerful key mappings ==
 
In the following, <tt><leader></tt> denotes your “leader” (<tt>:help mapleader</tt>), that is,
the prefix for user-defined mappings.
By default, the leader is the backslash character, but that may be changed by the user.
For example, to use a comma as a leader, put this in your <tt>.vimrc</tt>:
map <leader> ,
 
=== Buffer-local Insert-mode macros to speed up editing ===
 
(By [[User:David antos|D.A.]] 19:52, 8 Jul 2005 (CEST))
 
* I have remapped <leader> to comma (one hardly ever use commas just before a letter)
* two types of mappings: stand-alone and changing the previous word
* usage of mappings that change the previous word: type the name of the macro and ,ta (for tag, use your leader character instead of the comma); it created \start-\stop block of the macro
* put the code into <code>.vim/after/plugin/context.vim</code>
<pre>
let maplocalleader = mapleader
 
" Make start-stop block out of the previous word
imap <buffer> <LocalLeader>ta \start<Cr>\stop<Cr><Esc>4bhdiw$pj$pO
imap <buffer> <LocalLeader>tb \begin<Cr>\end<Cr><Esc>4bhdiw$pj$pO
 
" Itemize
imap <buffer> <LocalLeader>it \startitemize<Cr>\stopitemize<Esc>O\item<Space>
imap <buffer> <LocalLeader>en \startitemize[n]<Cr>\stopitemize<Esc>O\item<Space>
imap <buffer> <LocalLeader>i<Return> \item<Space>
 
" Font switching and emphasize
imap <buffer> <LocalLeader>em {\em }<Left>
imap <buffer> <LocalLeader>sc {\sc }<Left>
 
" Define... and setup...
imap <buffer> <LocalLeader>de \define
imap <buffer> <LocalLeader>se \setup
 
" Typing and type
imap <buffer> <LocalLeader>ty \type{}<Left>
imap <buffer> <LocalLeader>typ typing<LocalLeader>ta
 
" Quote and quotation
imap <buffer> <LocalLeader>" \quotation{}<Left>
imap <buffer> <LocalLeader>' \quote{}<Left>
</pre>
 
=== Key mappings borrowed from SciTE ===
 
If you use the stand-alone distribution for Windows/Linux.
You can reset the key mapping to speed ConTeXt compiling.
 
Just add the following code to your <tt>_vimrc</t>> (or <tt>.vimrc</tt> file under Linux) file:
<pre>
"run setup and complie, then open the result pdf file
map <F5> <Esc><Esc>:sil ! "D:\context\tex\setuptex.bat && texmfstart texexec.pl --autopdf --pdf '%'"<CR><CR>
 
"view the corresponding pdf file
map <F6> <Esc><Esc>:sil ! D:\"Program Files"\Adobe\Acrobat\Acrobat.exe %:p:r.pdf<CR><CR>
 
"run setup and make purge
map <F7> <Esc><Esc>:sil ! "D:\context\tex\setuptex.bat && texmfstart texutil.pl --purge"<CR><CR>
 
"run setup and make list of the current file
map <F8> <Esc><Esc>:sil ! "D:\context\tex\setuptex.bat && texmfstart texexec.pl --autopdf --pdf --list --result=%:p:r_list %"<CR><CR>
 
</pre>
 
=== Quickfix mappings ===
 
It is useful to define mappings for quickfix commands, to be able to navigate among ConTeXt errors.
For example:
nnoremap <silent> ]q :<c-u><c-r>=v:count1<cr>cnext<cr>zz
nnoremap <silent> [q :<c-u><c-r>=v:count1<cr>cprevious<cr>zz
Or install Tim Pope's <i>unimpaired</i> plugin.
 
== Makefiles ==
 
For your ConTeXt document, you can prepare a Makefile like this one (Contributed by [[User:Buggs|Buggs]]):
 
# An example Makefile to compile a context file, paper.tex
paper.pdf: paper.tex
context paper
test:
xpdf paper.pdf
clean:
rm *.aux *.bbl *.blg *.log *.tuc
 
If you put these mappings to your <code>.vimrc</code> file, you can then compile the document with F9 and preview it with F8:
 
" map ":make" to the F9 key
imap <F9> <ESC>:exe "lcd" fnameescape(expand("%:p:h"))<CR>:make<CR>
nmap <F9> :exe "lcd" fnameescape(expand("%:p:h"))<CR>:make<CR>
"map ":make test" to the F8 key
imap <F8> <ESC>:exe "lcd" fnameescape(expand("%:p:h"))<CR>:make test<CR>
nmap <F8> :exe "lcd" fnameescape(expand("%:p:h"))<CR>:make test<CR>
== Other useful Vim plugins ==
TexLet g:Tex_DefaultTargetFormat = 'cont'
 
== Powerful key mappings ==
 
In the following, <tt><leader></tt> denotes your “leader” (<tt>:help mapleader</tt>), that is,
the prefix for user-defined mappings.
By default, the leader is the backslash character, but that may be changed by the user.
For example, to use a comma as a leader, put this in your <tt>.vimrc</tt>:
map <leader> ,
 
=== Buffer-local Insert-mode macros to speed up editing ===
 
(By [[User:David antos|D.A.]] 19:52, 8 Jul 2005 (CEST))
 
* I have remapped <leader> to comma (one hardly ever use commas just before a letter)
* two types of mappings: stand-alone and changing the previous word
* usage of mappings that change the previous word: type the name of the macro and ,ta (for tag, use your leader character instead of the comma); it created \start-\stop block of the macro
* put the code into <code>.vim/after/plugin/context.vim</code>
<pre>
let maplocalleader = mapleader
 
" Make start-stop block out of the previous word
imap <buffer> <LocalLeader>ta \start<Cr>\stop<Cr><Esc>4bhdiw$pj$pO
imap <buffer> <LocalLeader>tb \begin<Cr>\end<Cr><Esc>4bhdiw$pj$pO
 
" Itemize
imap <buffer> <LocalLeader>it \startitemize<Cr>\stopitemize<Esc>O\item<Space>
imap <buffer> <LocalLeader>en \startitemize[n]<Cr>\stopitemize<Esc>O\item<Space>
imap <buffer> <LocalLeader>i<Return> \item<Space>
 
" Font switching and emphasize
imap <buffer> <LocalLeader>em {\em }<Left>
imap <buffer> <LocalLeader>sc {\sc }<Left>
 
" Define... and setup...
imap <buffer> <LocalLeader>de \define
imap <buffer> <LocalLeader>se \setup
 
" Typing and type
imap <buffer> <LocalLeader>ty \type{}<Left>
imap <buffer> <LocalLeader>typ typing<LocalLeader>ta
 
" Quote and quotation
imap <buffer> <LocalLeader>" \quotation{}<Left>
imap <buffer> <LocalLeader>' \quote{}<Left>
</pre>
 
=== Key mappings borrowed from SciTE ===
 
If you use the stand-alone distribution for Windows/Linux.
You can reset the key mapping to speed ConTeXt compiling.
 
Just add the following code to your <tt>_vimrc</t>> (or <tt>.vimrc</tt> file under Linux) file:
<pre>
"run setup and complie, then open the result pdf file
map <F5> <Esc><Esc>:sil ! "D:\context\tex\setuptex.bat && texmfstart texexec.pl --autopdf --pdf '%'"<CR><CR>
 
"view the corresponding pdf file
map <F6> <Esc><Esc>:sil ! D:\"Program Files"\Adobe\Acrobat\Acrobat.exe %:p:r.pdf<CR><CR>
 
"run setup and make purge
map <F7> <Esc><Esc>:sil ! "D:\context\tex\setuptex.bat && texmfstart texutil.pl --purge"<CR><CR>
 
"run setup and make list of the current file
map <F8> <Esc><Esc>:sil ! "D:\context\tex\setuptex.bat && texmfstart texexec.pl --autopdf --pdf --list --result=%:p:r_list %"<CR><CR>
 
</pre>
 
=== Quickfix mappings ===
 
It is useful to define mappings for quickfix commands, to be able to navigate among ConTeXt errors.
For example:
nnoremap <silent> ]q :<c-u><c-r>=v:count1<cr>cnext<cr>zz
nnoremap <silent> [q :<c-u><c-r>=v:count1<cr>cprevious<cr>zz
Or install Tim Pope's <i>unimpaired</i> plugin.
 
== Makefiles ==
 
For your ConTeXt document, you can prepare a Makefile like this one (Contributed by [[User:Buggs|Buggs]]):
 
# An example Makefile to compile a context file, paper.tex
paper.pdf: paper.tex
context paper
test:
xpdf paper.pdf
clean:
rm *.aux *.bbl *.blg *.log *.tuc
 
If you put these mappings to your <code>.vimrc</code> file, you can then compile the document with F9 and preview it with F8:
 
" map ":make" to the F9 key
imap <F9> <ESC>:exe "lcd" fnameescape(expand("%:p:h"))<CR>:make<CR>
nmap <F9> :exe "lcd" fnameescape(expand("%:p:h"))<CR>:make<CR>
"map ":make test" to the F8 key
imap <F8> <ESC>:exe "lcd" fnameescape(expand("%:p:h"))<CR>:make test<CR>
nmap <F8> :exe "lcd" fnameescape(expand("%:p:h"))<CR>:make test<CR>
 
{{Installation navbox}}
[[Category:Text Editors]]
134

edits

Navigation menu