From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA15802; Mon, 17 Nov 2003 17:40:17 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA16198 for ; Mon, 17 Nov 2003 17:40:16 +0100 (MET) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hAHGeD111703 for ; Mon, 17 Nov 2003 17:40:14 +0100 (MET) Received: from fistandantilus.takhisis.org (dhcp153.dmi.ens.fr [129.199.97.153]) by nef.ens.fr (8.12.10/1.01.28121999) with ESMTP id hAHGeC1P083573 for ; Mon, 17 Nov 2003 17:40:12 +0100 (CET) Received: by fistandantilus.takhisis.org (Postfix, from userid 3148) id 127E3274047; Mon, 17 Nov 2003 17:40:12 +0100 (CET) Date: Mon, 17 Nov 2003 17:40:12 +0100 From: Stefano Zacchiroli To: caml-list@inria.fr Subject: [Caml-list] vim - switching between .ml and .mli Message-ID: <20031117164012.GC2553@fistandantilus.takhisis.org> Mail-Followup-To: caml-list@inria.fr References: <20031117113030.GA2649@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031117113030.GA2649@localhost> User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; bononia:01 mli:01 issac:01 trotts:01 mli:01 python:01 python:01 buffer:01 buffer:01 bononia:01 mio:99 ero:99 reso:99 che:99 molto:99 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, Nov 17, 2003 at 03:30:30AM -0800, Issac Trotts wrote: > For those who use Vim and have the matchit.vim plugin installed, > here are a few lines to put in $HOME/.vim/ftplugin/ocaml.vim : Thanks! This is what I offer in exchange: support for switching from .ml to .mli with ",s" and ",S" (the latter split a new window). It requires vim-python in order to remember the previous position in a file: " switching between interfaces (.mli) and implementations (.ml) if !exists("g:did_ocaml_switch") && has("python") let g:did_ocaml_switch = 1 map ,s :call OCaml_switch_switch() map ,S :call OCaml_switch_switch_new() fun OCaml_switch_pynit() python << EOF import vim positions = {} def ocaml_save_position(): positions[vim.current.buffer.name] = vim.current.window.cursor def ocaml_restore_position(): try: vim.current.window.cursor = positions[vim.current.buffer.name] except KeyError: pass EOF endfun call OCaml_switch_pynit() fun OCaml_switch_switch() if (match(bufname(""), "\\.mli$") >= 0) python ocaml_save_position() exec "edit " . substitute(bufname(""), "\\.mli$", ".ml", "") python ocaml_restore_position() elseif (match(bufname(""), "\\.ml$") >= 0) python ocaml_save_position() exec "edit " . bufname("") . "i" python ocaml_restore_position() endif endfun fun OCaml_switch_switch_new() " as above but in a new window if (match(bufname(""), "\\.mli$") >= 0) python ocaml_save_position() exec "new " . substitute(bufname(""), "\\.mli$", ".ml", "") python ocaml_restore_position() elseif (match(bufname(""), "\\.ml$") >= 0) python ocaml_save_position() exec "new " . bufname("") . "i" python ocaml_restore_position() endif endfun endif -- ^Stefano Zacchiroli -- Master in Computer Science @ Uni. Bologna, Italy$ ^zack@{cs.unibo.it,debian.org,bononia.it} -- http://www.bononia.it/zack$ ^Frequentando il mio maestro mi ero reso conto [.] che la logica poteva$ ^servire a molto a condizione di entrarci dentro e poi di uscirne -Adso$ ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners