vim 完全配置文件
2015-11-08 13:19
393 查看
set fenc=utf-8 syntax on set number set shiftwidth=4 set tabstop=4 set autoindent set wrap set cindent set nocompatible set pastetoggle=<F3> imap [[ {<cr>}<c-o>O map <F4> :call CompileRunGcc()<CR> func! CompileRunGcc() exec "w" exec "!g++ % -o %<" endfunc map <F5> :call Run()<CR> func! Run() exec "! ./%<" endfunc map <F2> :!javac %<cr> map <F3> :!java %<<cr> map <F6> :call RunThisScript()<CR> function RunThisScript() let file_name = expand("%:p") let file_ext = expand("%:e") let file_cmd = "" "python 直接调用 if file_ext == "py" let file_cmd = '/usr/bin/python' let file_args = ' ' . file_name "c 需要提取第一行的编译参数 "如,当需要引入第三方库(以mysql为例)时,则在第一行添加: //-lmysqlclient -L/usr/local/mysql/include "文件中则可直接 #include <mysql/mysql.h> elseif file_ext == "c" let file_first_line = getline(1) let file_arg = "" if strpart(file_first_line, 0, 2) == '//' let file_arg = strpart(file_first_line, 2) "提取参数 endif let file_output_file = strpart(file_name, 0, strridx(file_name, '.c')) let file_args = ' -o '. file_output_file .' '. file_name . ' '. file_arg .' && '. file_output_file "将参数附加到编译命令之后 let file_cmd = '/usr/bin/cc' "php 直接调用 elseif file_ext == "php" let file_cmd = "/usr/local/php/bin/php" "php执行路径 let file_args = ' -f '. file_name "perl 直接调用 elseif file_ext == "perl" || file_ext == "pl" let file_cmd = "/usr/bin/perl" let file_args = " ". file_name "erlang 默认调用 main 函数, 可以确保 escript 和 noshell/shell 执行时一致 elseif file_ext == "erl" let file_output_file = strpart(expand("%"), 0, stridx(expand("%"), ".erl")) let file_cmd = "/usr/bin/erlc" let file_args = file_output_file .".". file_ext ." ; /usr/bin/erl -noshell -s ". file_output_file . " main -s init stop" "java 先调用 javac,再调用java elseif file_ext == "java" let file_output_file = strpart(expand("%"), 0, stridx(expand("%"), ".java")) let file_cmd = 'javac' let file_args = file_name ." && java ". file_output_file else echo "错误: 没有任何编译器匹配此文件类型, 请确认您的文件扩展名!" endif if file_cmd != "" if ! executable(file_cmd) echo file_cmd echo "The executable file to compile ". file_ext . " type files." else let cmd = "! ". file_cmd . ' ' . file_args "echo "执行命令: ". cmd exec cmd endif endif endfunction
相关文章推荐
- VIM编译器显示TAB和TAB转换为空格
- 菜鸟说给菜鸟听之VIM--入门篇(1)
- cygwin下vim方向键不好用的解决方案
- 安装使用Ubuntu之vim必须知道的细节
- Ruby学习笔记二帮助生成Vim添加代码头的代码
- ruby开发vim插件小结
- VIM中设置php自动缩进为4个空格的方法详解
- Vim命令高级用法
- linux Vim基本操作方法
- 使用python开发vim插件及心得分享
- linux系统中使用Vim删除偶数行或者奇数行
- Mac 配置VIM插件 提示"E492:Not an editor command:^M"
- vim配置文件
- Vim编辑器快捷键
- vim的配置(自动缩进,语法高亮等)
- [Linux学习笔记] Linux文本编辑器Vim/Vi
- VIM 去掉~M符号
- ctags --- 每天一个 Linux 命令
- 怎样管理 linux / mac 的配置文件
- 用Vim订阅OSChina RSS