Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to run g++ and show the results in a horizontal split in VIM

Tags:

vim

g++

I use this command :!g++ % -g -lm && a.exe & pause The result comes out in a new command prompt. I'm using gvim7.3. How can i make VIM to display the result in the same window (horizontal split)? Thanks in advance.

like image 807
user1431779 Avatar asked Jan 19 '26 12:01

user1431779


2 Answers

:make then :copen should do the trick. You can also close the window with :cclose.

like image 199
Nathan Avatar answered Jan 22 '26 03:01

Nathan


Try this:

:new +r\ !g++\ #\ -g\ -lm

That opens a new "window" and reads the output of the g++ command into it. Note that you need to use # instead of % because you have switch to a new buffer.

I'm not sure how to get && to work, so I would just create a script that compiles and executes.

You might want to also do "set nomod" so you can close that window without saving the file.

like image 27
TimK Avatar answered Jan 22 '26 05:01

TimK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!