This Sublime Text build system compiles a C++ program, then opens a new window in Terminal.app and runs it there upon pressing ctrl+b.
{
"shell_cmd": "g++-11 -std=c++20 '${file}' -o '${file_base_name}' && echo 'cd \"${file_path}/\"' > '/tmp/${file_base_name}' && echo './\"${file_base_name}\"' >> '/tmp/${file_base_name}' && echo read >> '/tmp/${file_base_name}' && chmod +x '/tmp/${file_base_name}' && open -a Terminal.app '/tmp/${file_base_name}'"
}
How would you write something similar for Vim?
You actually have a few options, so use whatever suits your needs the most.
You can use vim's built in terminal
:terminal(or:term; see:help :terminal), which is probably the easier way:Or you can use
:compilerwith:make(see:help :compileand:help 'makeprg'):