Changes

Jump to navigation Jump to search
1,020 bytes added ,  23:13, 6 July 2006
→‎context.vim: Some details added
This page will be about editing ConTeXt source in (g)vim.
== Filetype detection ==Tex (plain tex), latex and contextall use <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 plaintex or latex or context. If the first line of a *.tex file has the form %&<format>then this determined the file type: plaintex (for plain TeX), context (forConTeXt), or tex (for LaTeX). Otherwise, the file is searched for keywords tochoose context or tex. If no keywords are found, it defaults to plaintex.You can change the default by defining the variable g:tex_flavor to the format(not the file type) you use most. Use one of these: let g:tex_flavor = "plain" let g:tex_flavor = "context" let g:tex_flavor = "latex"Currently no other formats are recognized. * If you use ConTeXt most of the time, but occasionally use latex or plaintex, you can add the following to your <code>.vimrc</code> let g:tex_flavor = "context"* If you only use ConTeXt, you can add the following lines to filetype.vim : " ConTeXt augroup filetypedetect au! BufRead,BufNewFile *.tex setfiletype context augroup ENDso the next time you open a <code>*.tex</code> file, vim will recognise always recognize it as a context file.   == ftplugin and syntax file ==
Nikolai Weibull was the first one who wrote context.vim files and submitted them to the official vim cvs repository.
* [http://cvs.sourceforge.net/viewcvs.py/vim/vim7/runtime/ftplugin/context.vim runtime/ftplugin/context.vim] - filetype specific behaviour (like repeating comments at the beginning of line)
If you don't use LaTeX (if your <code>*.tex</code> files are mostly for ConTeXt), you can add the following lines to filetype.vim:
" ConTeXt
augroup filetypedetect
au! BufRead,BufNewFile *.tex setfiletype context
augroup END
so the next time you open a <code>*.tex</code> file in vim, context.vim will be loaded instead of tex.vim.
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>.
* proper URL highlighting ('%' doesn't start a comment, ...) [request by VnPenguin]
* perhaps borrow something from http://vim-latex.sourceforge.net/?
* Have a better filetype detection for *.tex files, to distinguish between plain tex, latex and context files(can this be deleted now? --[[User:Adityam|Aditya]])
* vim auto-complete for vim

Navigation menu