caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* VIM-hints
@ 1999-11-02 23:12 Markus Mottl
  0 siblings, 0 replies; only message in thread
From: Markus Mottl @ 1999-11-02 23:12 UTC (permalink / raw)
  To: OCAML

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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-11-03 20:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-02 23:12 VIM-hints Markus Mottl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).