nnoremap <F5> <Esc>:w<CR>:!g++ -std=c++11 -g % -o ./a.out && ./a.out<CR>
nnoremap <F7> <Esc>:w<CR>:!g++ -std=c++11 -g % -o ./a.out<CR>
nnoremap <F6> <Esc>:w<CR>:!g++ -std=c++11 -g % -o ./a.out && gdb ./a.out<CR>
最好使用nvim来写代码,实在是非常爽呢
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
" set number
set number
" open syntax highlighting
syntax on
" Use release branch (Recommend)
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
nnoremap <F5> <Esc>:w<CR>:!gnome-terminal -- bash -c "g++ -std=c++11 -g % -o ./a.out && time ./a.out && echo -e \"\\nPress any key to continue...\";read"<CR><CR>
" nnoremap <F7> <Esc>:w<CR>:!gnome-terminal -- bash -c "g++ -m32 -std=c++11 -W -g % -o ./a.out || read"<CR><CR>
nnoremap <F7> <Esc>:w<CR>:call Compile()<CR><CR>
nnoremap <F6> <Esc>:w<CR>:!gnome-terminal -- bash -c "g++ -std=c++11 -g % -o ./a.out && gdb ./a.out"<CR><CR>
func! Compile()
"exec "w"
if &filetype=='c'
exec "!gnome-terminal -- bash -c 'gcc -std=c11 % -o a.out || read'"
elseif &filetype=='cpp'
exec "!gnome-terminal -- bash -c 'g++ -std=c++11 % -o a.out || read'"
endif
endfunc