开发者

Annoyance when running scripts in Vim (Windows, Ruby)

I started using vim for my programming projects (mostly Ruby) and mostly everything works just as I want but I have a problem with compiling.

Lets say I am working on a Ruby script and I want to run it. I type :ruby sometging.rb (mapped to some other key). Then vim opens a new cmd.exe window and runs 'ruby something.rb'. Then it waits for me to press ENTER to close the window and continue working on the script.

Is there a way to configure vim on windows so that it always runs the script I'm working on in a separete window (always the开发者_开发百科 same one, if none exists => open one), and not ask me to confirm with enter?


Don't know about gvim, but in normal vim you could put something like

map R <ESC>:tabnew<CR><ESC>:;%!ruby filename.rb<CR>

in your ~/.vimrc which would execute a Ruby file in a newtab when pressing R in command mode.


I've not used Ruby, but for I've found Dr Chip's RunView plugin really useful for running other interpreted languages.

Once it's installed, you can enter:

:RunView! <interpreter>

(where <interpreter> is presumably 'ruby' in your case) and it will open a (vertically if you include the !) split window with the output from passing the contents of the current window to the interpreter. Each time it is run, a new result log is appended to the end of the file (with a date and time stamp separating them).

If you have any issues with it, I'd recommend you contact Dr Chip via the Vim mailing list: he's very helpful (in fact he wrote the original version of RunView in response to a request I made on the mailing list).


This isn't exactly perfect but I use this to launch Python scripts.

command -nargs=* PY3 !start cmd /K Python.exe "%:p" <args>

It starts up a window that stays alive and doesn't interfere with my VIM window. Unfortunately it doesn't load it into an existing window.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜