Difference between revisions of "Vim"
m (bugfix ;)) |
(Makefile example moved here from another page (contribution by Buggs)) |
||
Line 32: | Line 32: | ||
* some essential math support | * some essential math support | ||
* proper URL highlighting ('%' doesn't start a comment, ...) [request by VnPenguin] | * proper URL highlighting ('%' doesn't start a comment, ...) [request by VnPenguin] | ||
+ | * perhaps borrow something from http://vim-latex.sourceforge.net/? | ||
== Other useful vim plugins == | == Other useful vim plugins == | ||
Line 38: | Line 39: | ||
* spell-checker: http://www.vim.org/scripts/script.php?script_id=499, but native spell-checking support will be included in Vim 7 | * spell-checker: http://www.vim.org/scripts/script.php?script_id=499, but native spell-checking support will be included in Vim 7 | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Powerful key mappings == | == Powerful key mappings == | ||
Line 66: | Line 46: | ||
* two types of mappings: stand-alone and changing the previous word | * 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 | * 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 .vim/after/plugin/context.vim | + | * put the code into <code>.vim/after/plugin/context.vim</code> |
<pre> | <pre> | ||
let maplocalleader = mapleader | let maplocalleader = mapleader | ||
Line 95: | Line 75: | ||
imap <buffer> <LocalLeader>' \quote{}<Left> | imap <buffer> <LocalLeader>' \quote{}<Left> | ||
</pre> | </pre> | ||
+ | |||
+ | |||
+ | == Makefile == | ||
+ | |||
+ | 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 | ||
+ | texexec paper | ||
+ | |||
+ | test: | ||
+ | xpdf paper.pdf | ||
+ | |||
+ | clean: | ||
+ | rm *.bbl *.dvi *.aux *.log *.blg | ||
+ | |||
+ | If you put these mappings to your <code>.vimrc</code> file, you can than compile the document with F9 and preview it with F8: | ||
+ | |||
+ | " map ":make" to the F9 key | ||
+ | imap <F9> <ESC>:make<CR> | ||
+ | nmap <F9> :make<CR> | ||
+ | |||
+ | "map ":make test" to the F8 key | ||
+ | imap <F8> <ESC>:make test<CR> | ||
+ | nmap <F8> :make test<CR> | ||
+ | |||
+ | |||
+ | === MetaPost extension === | ||
+ | |||
+ | Should highlight the syntax between <code>btex/verbatimtex</code> ... <code>etex</code> as TeX. | ||
+ | |||
+ | This doesn't work 100% (problems with commands inside comments): If anyone knows how to repair that, please do so. It would be nice if this would have landed in the official metapost syntax highlighting script for vim one day. | ||
+ | |||
+ | unlet b:current_syntax | ||
+ | syn include @texTop syntax/tex.vim | ||
+ | " MetaPost has TeX inserts for typeset labels | ||
+ | " verbatimtex, btex, and etex will be treated as keywords | ||
+ | syn match mpTeXbegin "\(verbatimtex\|btex\)" | ||
+ | syn match mpTeXend "etex" | ||
+ | syn region mpTeXinsert start="\(verbatimtex\|btex\)"hs=e+1 end="etex"he=s-1 \ | ||
+ | contains=@texTop,mpTeXbegin,mpTeXend containedin=ALL keepend |
Revision as of 01:49, 3 August 2005
< Related Programs | Text editor >
This page will be about editing ConTeXt source in (g)vim.
Contents
context.vim
Nikolai Weibull was the first one who wrote context.vim files and submitted them to the official vim cvs repository. They will be part of the official Vim 7. However, as it is still in alpha state at the time of writing, you probably don't have those files in Vim 6.
You can download the files at:
- runtime/syntax/context.vim - syntax highlighting
- runtime/ftplugin/context.vim - filetype specific behaviour (like repeating comments at the beginning of line)
If you don't use LaTeX (if your *.tex
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 *.tex
file in vim, context.vim will be loaded instead of tex.vim.
It's mostly up to you which syntax highlighting scheme you prefer. context.vim
is a lighter version than tex.vim
. It knows some ConTeXt details that are not implemented in tex.vim
, while math and some other TeX features are not supported yet in context.vim
.
If you feel that something is missing, please contribute!
TODO
- extract data from texweb and create syntax highlighting definitions for ConTeXt
- add metafun macros (from metafun manual)
- enable metapost/metafun, JavaScript and XML inside 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/?
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 will be included in Vim 7
Powerful key mappings
a set of buffer-local insert-mode macros to speed up ConTeXt source editing (by 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
.vim/after/plugin/context.vim
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>
Makefile
For your ConTeXt document, you can prepare a Makefile like this one (Contributed by Buggs):
# An example Makefile to compile a context file, paper.tex paper.pdf: paper.tex texexec paper test: xpdf paper.pdf clean: rm *.bbl *.dvi *.aux *.log *.blg
If you put these mappings to your .vimrc
file, you can than compile the document with F9 and preview it with F8:
" map ":make" to the F9 key imap <F9> <ESC>:make<CR> nmap <F9> :make<CR> "map ":make test" to the F8 key imap <F8> <ESC>:make test<CR> nmap <F8> :make test<CR>
MetaPost extension
Should highlight the syntax between btex/verbatimtex
... etex
as TeX.
This doesn't work 100% (problems with commands inside comments): If anyone knows how to repair that, please do so. It would be nice if this would have landed in the official metapost syntax highlighting script for vim one day.
unlet b:current_syntax syn include @texTop syntax/tex.vim " MetaPost has TeX inserts for typeset labels " verbatimtex, btex, and etex will be treated as keywords syn match mpTeXbegin "\(verbatimtex\|btex\)" syn match mpTeXend "etex" syn region mpTeXinsert start="\(verbatimtex\|btex\)"hs=e+1 end="etex"he=s-1 \ contains=@texTop,mpTeXbegin,mpTeXend containedin=ALL keepend