From: Markus Mottl <mottl@miss.wu-wien.ac.at>
Message-Id: <199911022312.AAA11578@miss.wu-wien.ac.at>
Subject: VIM-hints
To: caml-list@inria.fr (OCAML)
Date: Wed, 3 Nov 1999 00:12:32 +0100 (MET)
Hello,
I guess that there are quite some people who use the editor VIM (Vi
Improved) out there (see: www.vim.org). I have just tried to find out some
more extras of VIM and found a very convenient way of building and
debugging OCaml programs so I thought that you might also want to learn
about it:
VIM allows you to specify patterns which scan output produced by the
compiler and/or during the make process. By teaching VIM the patterns that
normally appear when the OCaml-compilers find a bug, it is possible to have
the editor automatically load the corresponding file and place the cursor
at the exact line + column.
If you also bind, say, a function key to calling "make", you never have to
leave the editor anymore.
The following variable settings seem to be very useful for this purpose -
put them in your ".vimrc"-file:
---------------------------------------------------------------------------
map <F5> :make<RETURN>
au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly set expandtab hidden autowrite efm=%+AFile\ \"%f\"\\,\ line\ %l\\,\ characters\ %c-%*\\d:,%Z%m
---------------------------------------------------------------------------
The first line binds a function key to calling the appropriate "make" (the
latter can be configured with e.g. "set makeprg=gmake").
The second line (it's just one - this is important!) says what has to be
done when you create a new file or open an existing one with the
corresponding OCaml-suffixes. The options in this line have the following
meaning:
* "expandtab" - use spaces instead of tabs when the tabulator key is used
(I recommend this in general for sources).
* "hidden" - Very important! If you call "make" and there is an error,
VIM will open the file containing it, but forgets about
the one that you changed - no undo anymore! This option
orders VIM to not forget about old buffers...
* "autowrite" - if you set this, then you do not have to save the files
before executing "make" anymore.
* "efm" - the patterns for which VIM scans the output of the
building process. See the help on "quickfix" in VIM for
more details.
I have found that (at least for me) these features give quite some boost in
development speed, especially if you want to rename things or if a small
change requires many further changes in different parts of the program:
then making use of the above features will (in most cases) help you track
down all code parts that require an update - just "make" and let VIM do the
job...
Happy VIMing!
Regards,
Markus Mottl
-- Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:28 MET