ubuntu 下 vim 的配置

来源:互联网 发布:linux bus error 解决 编辑:程序博客网 时间:2024/05/22 17:13
set nocp  "去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限"set nusyntax onset autoindentset smartindentset ts=4set shiftwidth=4set rulerset showmatch "设置匹配模式,类似当输入一个左括号时会匹配相应的那个右括号set incsearch      "查询时非常方便    例如 : book  b, bo, booset nomore "------解决乱码,不知有效否?------------------------- set fileencodings=utf-8,gb18030,gbk,gb2312set termencoding=utf-8"set encoding=utf-8,gb18030 "---------------------------------------------"定义函数SetTitle,自动插入文件头func SetTitle()if &filetype == 'c'call setline(1, "#include <stdio.h>")call setline(2, "#include <string.h>")call setline(3, "")call setline(4, "int main() {")elseif &filetype == 'cpp'call setline(1, "#include <iostream>")call setline(2, "#include <cstdio>")call setline(3, "#include <cstring>")call setline(4, "#include <string>")call setline(5, "#include <algorithm>")call setline(6, "")call setline(7, "using namespace std;")call setline(8, "")call setline(9, "int main() {")endifendfunc set completeopt=longest,menu"新建.c,.h,.sh,.java文件,自动插入文件头autocmd BufNewFile *.[ch],*.sh,*.cpp,*.java exec ":call SetTitle()""--------------------------------------------- "定义CompileRun函数,用来调用进行编译和运行func! CompileRun()exec "w""C程序if &filetype == 'c'exec "!gcc % -g -o %<.exe"exec "! ./%<.exe"elseif &filetype == 'cpp'exec "!g++ % -g -o %<.exe"exec "! ./%<.exe""Java程序elseif &filetype == 'java'exec "!javac %"exec "!java %<"endifendfunc"结束定义CompileRun"-------------------------" ======= 编译 && 运行 ======= "" 编译源文件func! CompileCode()    exec "w"    if &filetype == "c"        exec "!gcc -Wall -std=c99 %<.c -o %<"    elseif &filetype == "cpp"        exec "!g++ -Wall -std=c++98 %<.cpp -o %<"    elseif &filetype == "java"        exec "!javac %<.java"    endifendfunc" 运行可执行文件func! RunCode()    exec "w"    if &filetype == "c" || &filetype == "cpp" || &filetype == "haskell"         exec "! ./%<"    elseif &filetype == "java"        exec "!java %<"    endifendfunc


原创粉丝点击