Vim - Displaying Code Output in a New Window á la Textmate?
Posted
by Michael Density
on Super User
See other posts from Super User
or by Michael Density
Published on 2010-04-23T02:24:36Z
Indexed on
2010/04/23
2:33 UTC
Read the original article
Hit count: 307
A few months back I switched from Textmate to Vim. Overall I really love Vim, but one of the things I miss from Textmate is using the ⌘R command to run Ruby code and having the results neatly pop up in a new, scrollable window. Obviously, Vim is capable of running Ruby code and displaying the output with :w !ruby
. The only downside to this is that if the resulting output is too long I can't scroll through it.
To combat this problem I tried modifying a :redir
function from Vim Tips. It looks like this:
function! TabNew(cmd)
redir => message
silent execute a:cmd
redir END
tabnew
silent put=message
set nomodified
endfunction
command! -nargs=+ -complete=command TabNew call TabNew(<q-args>)
Now the output from Ruby is put into a new tab. However, I can't get it to pop up in a new, separate window. Changing tabnew
to new
just sends the output to a split in the same window.
The other problem is that a visible ^M
gets appended to the end of each line, so the output ends up looking like this, which is kind of bothersome:
Hello World!^M
So, is there any way to get the output into a separate window without the ^M
appended to the end? Are there any plugins I should be trying to achieve this Textmate-like effect for code output?
© Super User or respective owner