Created
December 13, 2020 15:10
-
-
Save ayoubjamouhi/fb5763f6fd3f25818e8504e7b3f6ce54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! TermWrapper(command) abort | |
if !exists('g:split_term_style') | let g:split_term_style = 'vertical' | endif | |
if g:split_term_style ==# 'vertical' | |
let buffercmd = 'vnew' | |
elseif g:split_term_style ==# 'horizontal' | |
let buffercmd = 'new' | |
else | |
echoerr 'ERROR! g:split_term_style is not a valid value (must be ''horizontal'' or ''vertical'' but is currently set to ''' . g:split_term_style . ''')' | |
throw 'ERROR! g:split_term_style is not a valid value (must be ''horizontal'' or ''vertical'')' | |
endif | |
if exists('g:split_term_resize_cmd') | |
exec g:split_term_resize_cmd | |
endif | |
exec buffercmd | |
exec 'term ' . a:command | |
exec 'startinsert' | |
endfunction | |
command! -nargs=0 CAR call TermWrapper(printf('g++ -std=c++11 %s && ./a.out', expand('%'))) | |
command! -nargs=1 CompileAndRunWithFile call TermWrapper(printf('g++ -std=c++11 %s && ./a.out < %s', expand('%'), <args>)) | |
autocmd FileType cpp nnoremap <Buffer><F5>fw CAR<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment