views:

59

answers:

3

On my .gvimrc, I have the following line:

map <f4> :!./%<  

On a source file, I have to press F4 and then enter, but it works correctly, shows the output, and hangs until I press enter again.

If I change it for:

map <f4> :!./%< <CR>

It behaves shows the output, but doesn't wait until I press enter (and so the output becomes impossible to read).

Is there any way to show the output of a program, and hang until I press enter, without having to press enter before of the command, without having to open a separate window?

A: 

See :help redir. You can redirect that output to a register and dump it into a buffer.

To give you an idea of how it works, I have this in my vimrc for viewing results from :g/.

"" Puts the last g search command in a new buffer -- clobbers your c buffer
cabbrev what :redir @c<CR>:g//<CR>:redir END<CR>:new<CR>:put! c<CR><CR>
pydave
+3  A: 

Your second mapping should work correctly. Sometimes this issue is caused by having an extra space at the end of a mapping.

too much php
A: 

Your second mapping should work correctly. A useful alternative though is to install Dr Chip's RunView plugin. This can be used to have a vertically split window with the script you're editing in one pane and the output from the script in the other pane. Every time you hit the key you've mapped, the output from the script is added to the output pane.

Very useful for debugging scripts.

Al