sorry for this offtopic mail, but I asked this on the vim-user
mailing list and git no answer...
What I wnat to do seems to be simple: I want to write a script
with vim and -- without saveing it -- pass it to the ruby interpreter
and get back the output including stderr AND stdout back into a new
buffer.
this.possible? && if true
聽聽anser = how.ask(self)
end
sorry for this offtopic mail, but I asked this on the vim-user
mailing list and git no answer...
What I wnat to do seems to be simple: I want to write a script
with vim and -- without saveing it -- pass it to the ruby interpreter
and get back the output including stderr AND stdout back into a new
buffer.
this.possible? && if true anser = how.ask(self)
end
Evening.nice!
mcc
I pulled this from the web, or the mailing list, somewhere..... a google on it should point you to the correct author...
I've wanted this myself, but never quite got there.
* You can use :w !ruby to run the current buffer without saving it and
see the output.
* You can use :r !ruby % to run the current buffer AFTER saving it and
and get it's output to the same buffer.
* You can use :e to open new buffers
I've never found a good way to bring them together into a nice round
trip shortcut, and unfortunately I don't know if they'll suit your needs
anyway since :r still writes out a temporary file...
路路路
On Fri, 2006-04-28 at 02:56 +0900, Meino Christian Cramer wrote:
What I wnat to do seems to be simple: I want to write a script
with vim and -- without saveing it -- pass it to the ruby interpreter
and get back the output including stderr AND stdout back into a new
buffer.
Meino Christian Cramer wrote:
> Hi,
>
> sorry for this offtopic mail, but I asked this on the vim-user
> mailing list and git no answer...
>
> What I wnat to do seems to be simple: I want to write a script
> with vim and -- without saveing it -- pass it to the ruby interpreter
> and get back the output including stderr AND stdout back into a new
> buffer.
>
> this.possible? && if true
> anser = how.ask(self)
> end
>
> Evening.nice!
> mcc
>
>
>
>
>
I pulled this from the web, or the mailing list, somewhere..... a google
on it should point you to the correct author...
short form of descriptions
<CTRL-I> execute and paste results in left side of vertical split
<CTRL-L><CTRL-W> close left side of vertical split
Thanks a lot for that trick, Reid !
But this only write the buffer, start ruby, exute that file with ruby
with ridirected output to another file and reads back that file into
vim. Additionally it does not check, whether both files already
exist...thex will be overwritten simply.
I wanted to exeute ruby with the buffer contents without writing to
the disk at all for that reason.
Is this possible ?
Ruby!
mcc
路路路
From: Reid Thompson <reid.thompson@ateb.com>
Subject: Re: OT: Vim->Ruby and back ?
Date: Fri, 28 Apr 2006 03:05:21 +0900
[...]
} > Meino Christian Cramer wrote:
} > > Hi,
} > >
} > > sorry for this offtopic mail, but I asked this on the vim-user
} > > mailing list and git no answer...
} > >
} > > What I wnat to do seems to be simple: I want to write a script
} > > with vim and -- without saveing it -- pass it to the ruby interpreter
} > > and get back the output including stderr AND stdout back into a new
} > > buffer.
[...]
}
} Thanks a lot for that trick, Reid !
}
} But this only write the buffer, start ruby, exute that file with ruby
} with ridirected output to another file and reads back that file into
} vim. Additionally it does not check, whether both files already
} exist...thex will be overwritten simply.
}
} I wanted to exeute ruby with the buffer contents without writing to
} the disk at all for that reason.
}
} Is this possible ?
I can get you stderr and stdout mised together, not in separate files:
0G"ryG:new
"rp:%!ruby
This yanks the entire buffer into register r, opens a new window, pastes
register r into the window, feeds the entire buffer into ruby's stdin and
replaces the buffer with what the script writes to stdout or stderr.
Unfortunately, I don't know how to distinguish between output to stdout and
stderr. Since you are writing the script, however, you should know which is
which.
} Ruby!
} mcc
--Greg
路路路
On Fri, Apr 28, 2006 at 11:29:35AM +0900, Meino Christian Cramer wrote:
[...]
} I can get you stderr and stdout mised together, not in separate files:
}
} 0G"ryG:new
} "rp:%!ruby
Sorry to respond to my own post, but this is a much nicer-looking (and
tested!) version of the above:
:%y r|new|pu r|%!ruby
} This yanks the entire buffer into register r, opens a new window, pastes
} register r into the window, feeds the entire buffer into ruby's stdin and
} replaces the buffer with what the script writes to stdout or stderr.
} Unfortunately, I don't know how to distinguish between output to stdout and
} stderr. Since you are writing the script, however, you should know which is
} which.
}
} } Ruby!
} } mcc
} --Greg
--Greg
路路路
On Fri, Apr 28, 2006 at 07:50:27AM -0400, Gregory Seidman wrote:
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.
How about
:vmap <C-R> y:exe "ruby " . getreg()<CR>
Mark some text in visual mode and press <C-R> to send it to the builtin Ruby interpreter. Note that the interpreter isn't restarted upon each invocation, so previous definitions stay valid, which may or may not be what you need.
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