Changes

Jump to navigation Jump to search
1,551 bytes added ,  11:32, 30 October 2016
no edit summary
http://www.vim.org/
This page is about editing ConTeXt source in Vim, gVim, MacVim, NeoVim, and other Vim clones. Some of the described features are available only in Vim v8.0.0047 or later: they will be noted below.
== Filetype A note on filetype detection ==TeX (Plain TeX), LaTex and ConTeXt all use the <code>.tex</code> 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 <code>plaintex</code> or <code>latex</code> or <code>context</code>.
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>. If the first line of a <codett>*.tex</codett> file has the form
%&<format>
then this determines the file type: <codett>plaintex</codett> (for Plain TeX), <codett>context</codett> (forConTeXt), or <codett>tex</codett> (for LaTeX). Otherwise, the file is searched for keywords tochoose <codett>context</codett> or <codett>tex</codett>. If no keywords are found, it defaults to <codett>plaintex</codett>.You can change the default by defining the variable <codett>g:tex_flavor</codett> to the format
(not the file type) you use most. Use one of these:
let g:tex_flavor = "plain"
Currently no other formats are recognized.
* If you use ConTeXt most of the time, but occasionally use LaTeX or Plain TeX, you can add the following to your <codett>.vimrc</codett>
let g:tex_flavor = "context"
* If you only use ConTeXt, you can add the following lines to <codett>filetype.vim</codett>:
" ConTeXt
augroup filetypedetect
au! BufRead,BufNewFile *.tex setfiletype context
augroup END
so the next time you open a <codett>*.tex</codett> file, Vim will always recognize it as a ConTeXt document.
== Spell-checker ==
Vim 7 or later has a built-in spell checker. To enable Vim's spell checkingit or disable it, use:
:set spell
or :set nospellrespectively.To set the language to be used for spell checking, set the `<tt>spelllang` </tt> option accordingly. For example:
:set spelllang=en_us
Use lowercase letters (<codett>en_us</codett>, not <codett>en_US</codett>).You can put such lines in your <codett>.vimrc</codett> if you like.
== ftplugin and syntax file Using ConTeXt in Vim ==
Nikolai Weibull was the first one who wrote <tt>context.vim</tt> files and submitted them to the official vim cvs Vim repository.They are part of the official Vim 7, and were expanded and improved in Vim 8.
<b>If you are using an older Vimfeel that something is missing, you can download the files at:* [http://cvs.sourceforge.net/viewcvs.py/vim/vim7/runtime/syntax/context.vim runtime/syntax/context.vim] - syntax highlighting* [http://cvs.sourceforge.net/viewcvs.py/vim/vim7/runtime/ftplugin/context.vim runtime/ftpluginplease contribute!</context.vim] - filetype specific behaviour (like repeating comments at the beginning of line)b>
Information about providing feedback is in the header of the source scripts.
It's mostly up to you which syntax highlighting scheme you prefer. <code>context.vim</code> is a lighter version than <code>tex.vim</code>. It knows some ConTeXt details that are not implemented in <code>tex.vim</code>, while math and some other TeX features are not supported yet in <code>context.vim</code>.=== Typesetting ===
The recommended way to typeset a ConTeXt document is to use the <tt>ConTeXt<b/tt>command. Just type: :ConTeXtto typeset the document in the current buffer. Typesetting happens in the background if you are using Vim 8.0.0047 or later,so you may continue working on your document. If you feel that something there are errors, the quickfix window opens automaticallyto show the errors (one error per line). The cursor stays in the main document, so your typing workflow is missingnotdisrupted. You may use standard quickfix commands to jump between errors: <tt>:cfirst</tt>, <tt>:cprev</tt>,<tt>:cnext</tt>, please contribute!etc… (see <tt>:help quickfix</btt>). It is useful to add mappings for these commands. 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>zzOr install Tim Pope's unimpaired plugin.
=== TODO ===If your document is typeset without errors, a <tt>Success!</tt> message appears.
* extract data from texweb and create syntax highlighting definitions for The <tt>:ConTeXt* add metafun macros (from metafun manual)* enable metapost</metafuntt> command accepts an optional path, JavaScript and XML inside ConTeXtin case you want to typeset a document different* some essential math support* proper URL highlighting from the current one ('%' doesn't start a comment, ...useful for big projects) [request by VnPenguin]* perhaps borrow something from http://vim-latex.sourceforge.net/?* vim auto-complete for vim
== compiler plugin ==You may check the status of your ConTeXt jobs with <tt>:ConTeXtJobStatus</tt>, and you may stop allrunning jobs with <tt>:ConTeXtStopJobs</tt>.
Context complier plugin for vim An alternative way to typeset a document is available from httpto use <tt>:make</tt>. ''Make sure that the current workingdirectory is set to the path to the file you want to compile'' (set with <tt>:lcd …</tt>), and type: :makeIf a <tt>Makefile</wwwtt> is present in the working directory, it will be used.vimOtherwise, <tt>mtxrun</tt> willbe invoked directly.org/scriptsNote that <tt>:make</scripttt> always performs synchronous typesetting.php?script_id=1925
After installing thisIt is recommended that you map the above commands. For example, you can may add nnoremap <silent> <leader>tt :<c-u>update<cr>:ConTeXt<cr>to your <tt>.vimrc</tt>, or (better) nnoremap <buffer> <silent> <leader>tt :<c-u>update<cr>:ConTeXt<cr>to <tt>~/.vim/after/ftplugin/context.vim</tt>, after which pressing <tt>\tt</tt> (where <tt>\<tt> is your leader key) will save (if necessary) and compile a TeX the file using.
You may customize the path to the <tt>mtxrun</tt> executable by setting <tt>g:make %context_mtxrun</tt>.For example, if you want to use your ConTeXt Beta installation at <tt>~/Applications/ConTeXt-Beta</tt>,you may set the variable as follows: let g:context_mtxrun = 'PATH=$HOME/Applications/ConTeXt-Beta/tex/texmf-osx-64/bin:$PATH mtxrun'
which will also highlight the error messages. If you prefer keymappings, you can addTODO: <tt>g:context_synctex</tt>
nmap Finally, you may pass <F5tt> mtxrun</tt> additional options by putting them in <tt>g:make %context_extra_options<cr/tt>.
to your <code>.vimrc</code> or your <code>ftplugin/context.vim</code>For each of the above variable, a corresponding buffer-local variable exists, whose value, if defined, after which pressing <code><F5></code> will compile take precedenceover the fileglobal value.
== Other useful vim plugins ==
* autocomplete: http://vim.sourceforge.net/scripts/script.php?script_id=182, almost undocumented, but life-saving
* spell-checker: http://www.vim.org/scripts/script.php?script_id=499, but native spell-checking support is included in Vim 7 (see above).
 
=== TODO ===
 
* extract data from texweb and create syntax highlighting definitions for ConTeXt
* some essential math support
* proper URL highlighting ('%' doesn't start a comment, ...) [request by VnPenguin]
* perhaps borrow something from http://vim-latex.sourceforge.net/?
== using latex-suite ==
134

edits

Navigation menu