From: Mauricio Fernandez Date: 2006-04-28T23:46:39+09:00 Subject: Re: OT: Vim->Ruby and back ? On Fri, Apr 28, 2006 at 12:55:02PM +0900, Gregory Brown wrote: > On 4/27/06, Meino Christian Cramer wrote: > > >E499: Empty file name for '%' or '#', only works with ":p:h" > > > >(dont know before, that the error message are in Chinese ... ;O) > > > >And now ? > > hmm... looks like it needs to be run against a saved file. :( > > I hope that someone finds a solution to this, because I would like to > add somethign to my .vimrc that can do what you want. Here's one idea + cheap implementation: * F7 in visual mode evaluates the selected area; temporary files are used so the original one isn't overwritten. The output (stdout & stderr) is shown in a new vsplit window (on the right) * F7 in normal and insert modes evaluate the whole buffer; the cursor position is preserved (warning: overwrites the 'z' mark) * S-F7 kills the stdout/stderr buffer; it is also removed from the minibufexplorer function! Ruby_eval_vsplit() range let src = tempname() let dst = tempname() execute ": " . a:firstline . "," . a:lastline . "w " . src execute ":silent ! ruby " . src . " > " . dst . " 2>&1 " execute ":redraw!" execute ":vsplit" execute "normal \l" execute ":e! " . dst execute "normal \h" endfunction vmap :call Ruby_eval_vsplit() nmap mzggVG`z imap a map l:bw imap -- Mauricio Fernandez - http://eigenclass.org - singular Ruby