caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <mottl@miss.wu-wien.ac.at>
To: caml-list@inria.fr (OCAML)
Subject: VIM-hints
Date: Wed, 3 Nov 1999 00:12:32 +0100 (MET)	[thread overview]
Message-ID: <199911022312.AAA11578@miss.wu-wien.ac.at> (raw)

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



                 reply	other threads:[~1999-11-03 20:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199911022312.AAA11578@miss.wu-wien.ac.at \
    --to=mottl@miss.wu-wien.ac.at \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).