Basically what I want is a keyboard shortcut in vim that lets me [compile and] run the currently being edited C, C++ or Python program. In psuedocode:
when a
I know I came here 7 years later. I tried the code of other answers and the result didn't satisfied me, so I tried this:
autocmd filetype cpp nnoremap :wterm ++shell g++ %:p -o %:p:r && %:p:r
When F9 is pressed, it (like all the answers above) compiles and executes the current file. The output is displayed in a :terminal section splitted screen. You can change the g++ command to run another language code.
It is saved in a gist, with another mapping to display the output, also in a splitted section, but in a new file, so you can save the output.
Hopefully it could help someone.