Friday, May 9, 2014

Re: How can I put the output of a code in a buffer ?

Gary Johnson writes:
> :new | :r !ruby %
...
> Note that the % is expanded to the name of the current buffer before
> the focus is changed to the new buffer.

Not when I test it. I get:

E499: Empty file name for '%' or '#', only works with ":p:h"

for "VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 4 2012 04:25:35)".
Does it work differently in other versions?

> Note also that with this method there will be an extra, empty line at
> the top of the new buffer.

You can change the behavior to put the line at the end of the buffer by
specifying a line number of zero to the read command:

:new | :0r !ruby filename

It's difficult to regain control of a ex mode : command after a ! in
order delete the extra line entirely, but I expect it can be done.

Elijah

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment