1个回答
展开全部
这个得慢慢配置,需要学习一些知识,我把我写的脚步给你,复制到~/.vimrc
imap<F5> :<ESC>:wa<CR>:call Do_OneFileCompile()<CR>
function Do_OneFileCompile()
if expand("%:p:h") != getcwd()
echohl WarningMsg | echo "Fail to compile, no such file in current directory!"
| echohl none
exit -1
endif
let sourcefile_name = expand("%:t")
if (sourcefile_name == "" || (&filetype != "c" && &filetype != "cpp"))
echohl WarningMsg | echo "It's not a \"c\" or \"cpp\" file!"
| echohl none
exit -2
endif
let sourcefile_name = expand("%:r")
if &filetype == "c"
execute "!gcc\ -g\ -o\ " . sourcefile_name . "\ %"
elseif &filetype == "cpp"
execute "!g++\ -g\ -o\ " . sourcefile_name . "\ %"
endif
let exec_filename = expand("%:p:h") . '/' . expand("%:r")
echo exec_filename
execute "!chmod +x " . exec_filename
execute "!gnome-terminal -e ' " . exec_filename . "'"
endfunction
imap<F5> :<ESC>:wa<CR>:call Do_OneFileCompile()<CR>
function Do_OneFileCompile()
if expand("%:p:h") != getcwd()
echohl WarningMsg | echo "Fail to compile, no such file in current directory!"
| echohl none
exit -1
endif
let sourcefile_name = expand("%:t")
if (sourcefile_name == "" || (&filetype != "c" && &filetype != "cpp"))
echohl WarningMsg | echo "It's not a \"c\" or \"cpp\" file!"
| echohl none
exit -2
endif
let sourcefile_name = expand("%:r")
if &filetype == "c"
execute "!gcc\ -g\ -o\ " . sourcefile_name . "\ %"
elseif &filetype == "cpp"
execute "!g++\ -g\ -o\ " . sourcefile_name . "\ %"
endif
let exec_filename = expand("%:p:h") . '/' . expand("%:r")
echo exec_filename
execute "!chmod +x " . exec_filename
execute "!gnome-terminal -e ' " . exec_filename . "'"
endfunction
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询