VIM 一键编译
2014-07-04 16:24
253 查看
第一种方法 去VIM官网下个CVIM插件(http://www.vim.org/scripts/script.php?script_id=213)应该是这个地址,不是的话,自己去VIM官网输入CVIM关键字搜索 直接解压到你的.vim文件夹中(就是专门放VIM插件的文件夹) 然后命令如下(只针对C和C++文件,其他文件无效): F9 compile and link Alt-F9 write buffer and compile Ctrl-F9 run executable Shift-F9 set command line arguments Shift-F2 switch between source files and header files 第二种方法(你可以自己加入java之类的一次编译运行,很简单) 在vim的配置文件中加入: " 编译C源文件 fun! CompileGcc() exec "w" let compilecmd="!gcc -Wall -ansi -pedantic -std=c99 " let compileflag="-o %<" exec compilecmd." % ".compileflag endfunc " 编译C++源文件 fun! CompileCpp() exec "w" let compilecmd="!g++ -g -Wall -pedantic -std=c++98 " let compileflag="-o %<" exec compilecmd." % ".compileflag endfunc " 根据文件类型自动选择相应的编译函数 func! CompileCode() exec "w" if &filetype == "c" exec "call CompileGcc()" elseif &filetype == "cpp" exec "call CompileCpp()" endif endfunc " 运行可执行文件 func! RunResult() exec "w" if &filetype == "c" exec "! %<" elseif &filetype == "cpp" exec "! %<" endif endfunc " <F7>一键保存、编译 map <F7> :call CompileCode()<CR> imap <F7> <ESC>:call CompileCode()<CR> vmap <F7> <ESC>:call CompileCode()<CR> " <F5>一键保存、运行 map <F5> :call RunResult()<CR> imap <F5> <ESC>:call RunResult()<CR> vmap <F5> <ESC>:call RunResult()<CR>
相关文章推荐
- 在VIM中添加一键编译和一键运行
- 在VIM中添加一键编译和一键运行
- vim 添加一键编译和运行
- vim 一键编译运行
- VIM2:在VIM中添加一键编译和一键运行
- 在VIM中添加一键编译和一键运行
- linux下vim配置之一键编译运行
- Ubuntu&红帽的vim通用配置(文件头+一键编译执行C/C++/Java单文件)
- VIM 一键编译
- VIM一键编译C程序
- Ubuntu&红帽的vim通用配置(文件头+一键编译执行C/C++/Java单文件)
- gVim/Vim 一键编译、连接、运行 C/C++ 单文件
- vim添加一键编译
- vim 一键编译运行C、C++等程序
- vim 一键编译JAVA,c++
- 在VIM中添加一键编译和一键运行
- vim 一键编译运行c++,c,java,python, shell
- Vim 一键编译、连接、运行 C/C++ 单文件(Windows 与 Linux通用)
- Vim C/C++的一键编译
- vim 一键编译运行