• 我的Gvim配置


    "********************************************
    " _vimrc/_gvimrc for windows
    " BY Douboer
    "********************************************

    "
    " echo "loading _vimrc ... "
    "

    set nocompatible
    source $VIMRUNTIME/vimrc_example.vim
    source $VIMRUNTIME/mswin.vim
    behave mswin

    set diffexpr=MyDiff()
    function MyDiff()
    let opt = '-a --binary '
    if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
    if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
    let arg1 = v:fname_in
    if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
    let arg2 = v:fname_new
    if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
    let arg3 = v:fname_out
    if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
    silent execute '!"C:\Vim\vim70\diff" -a' . opt . v:fname_in . ' ' . v:fname_new . ' > ' . v:fname_out
    endfunction


    "
    " 不同中文编码显示
    " 同时支持GBK和UTF-8编码
    "
    "set fileencoding=gb18030
    "set fileencodings=utf-8,gb18030,utf-16,big5
    set fileencodings=ucs-bom,utf-8,cp936
    set fileencoding=utf-8
    set encoding=cp936 "set encoding=utf-8
    cd c:\Users\Administrator\Desktop
    "cd d:\vim
    "
    " 设置字体
    "
    set guifont=Consolas:h20:cANSI

    "
    " 启动最大化, 设置颜色方案
    "
    " winsize 1024 768
    au GUIEnter * simalt ~x
    colorscheme darkblue

    "
    "自动缩进
    "
    set autoindent

    "
    " 设置tab制表符为4个空格
    "
    set ts=4
    set expandtab
    set shiftwidth=4
    set cinoptions=>4,e0,n0,f0,{0,}0,^0,:s,=s,l0,gs,hs,ps,ts,+s,c3,C0,(2s,us,
    \U0,w0,m0,j0,)20,*30
    "
    "set cindent
    "

    "
    " 展开显示文件类型菜单
    "
    let do_syntax_sel_menu = 1 | runtime! synmenu.vim | aunmenu &Syntax.&Show\ filetypes\ in\ menu

    "
    " 设置语法
    "
    "if &filetype != 'javacc'
    " setlocal filetype=javacc
    "endif
    "set syntax=javacc
    "cal SetSyn("cpp")
    "cal SetSyn("vb")
    "cal SetSyn("perl")
    "cal SetSyn("awk")

    "
    " 备份文件放在指定目录
    "
    set backupdir=C:\tmp

    "
    " 没有警告音和视觉警告
    "
    set vb t_vb=

    "
    " 禁用swf交换文件
    "
    setlocal noswapfile

    "
    " 显示行号
    "
    set number

    "
    " 隐藏工具条
    "
    " see :help 'guioptions'
    "
    set guioptions-=T
    "set guioptions-=m

    "
    " 状态条,显示字节数,列数,行数,当前行等信息
    "
    set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
    set laststatus=2 " always show the status line

    "
    "auto-comments for // and /* */
    "setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
    "
    "disable auto-comments for //
    "setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,f://
    "
    "disable auto-comments for // and /* */
    "
    "setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*
    setlocal comments=""

    set tags=C:\Users\Administrator\Desktop\vim\tags

    "单个文件编译
    map <F5> :call Do_OneFileMake()<CR>
    function Do_OneFileMake()
    if expand("%:p:h")!=getcwd()
    echohl WarningMsg | echo "Fail to make! This file is not in the current dir! Press <F7> to redirect to the dir of this file." | echohl None
    return
    endif
    let sourcefileename=expand("%:t")
    if (sourcefileename=="" || (&filetype!="cpp" && &filetype!="c"))
    echohl WarningMsg | echo "Fail to make! Please select the right file!" | echohl None
    return
    endif
    let deletedspacefilename=substitute(sourcefileename,' ','','g')
    if strlen(deletedspacefilename)!=strlen(sourcefileename)
    echohl WarningMsg | echo "Fail to make! Please delete the spaces in the filename!" | echohl None
    return
    endif
    if &filetype=="c"
    if g:iswindows==1
    set makeprg=gcc\ -o\ %<.exe\ %
    else
    set makeprg=gcc\ -o\ %<\ %
    endif
    elseif &filetype=="cpp"
    if g:iswindows==1
    set makeprg=g++\ -o\ %<.exe\ %
    else
    set makeprg=g++\ -o\ %<\ %
    endif
    "elseif &filetype=="cs"
    "set makeprg=csc\ \/nologo\ \/out:%<.exe\ %
    endif
    if(g:iswindows==1)
    let outfilename=substitute(sourcefileename,'\(\.[^.]*\)' ,'.exe','g')
    let toexename=outfilename
    else
    let outfilename=substitute(sourcefileename,'\(\.[^.]*\)' ,'','g')
    let toexename=outfilename
    endif
    if filereadable(outfilename)
    if(g:iswindows==1)
    let outdeletedsuccess=delete(getcwd()."\\".outfilename)
    else
    let outdeletedsuccess=delete("./".outfilename)
    endif
    if(outdeletedsuccess!=0)
    set makeprg=make
    echohl WarningMsg | echo "Fail to make! I cannot delete the ".outfilename | echohl None
    return
    endif
    endif
    execute "silent make"
    set makeprg=make
    execute "normal :"
    if filereadable(outfilename)
    if(g:iswindows==1)
    execute "!".toexename
    else
    execute "!./".toexename
    endif
    endif
    execute "copen"
    endfunction
    "进行make的设置
    map <F6> :call Do_make()<CR>
    map <c-F6> :silent make clean<CR>
    function Do_make()
    set makeprg=make
    execute "silent make"
    execute "copen"
    endfunction
    cd f:\vim

  • 相关阅读:
    css常用属性记录
    js字符串常用方法总结
    mongoose基本操作
    本地存储API
    历史相关API
    自定义播放器
    HTML5全屏操作API
    HTML5自定义属性操作
    HTML5类操作
    案例:3D切割轮播图
  • 原文地址:https://www.cnblogs.com/cs1003/p/2747194.html
Copyright © 2020-2023  润新知