_vimrc

来源:互联网 发布:php去掉反斜线 编辑:程序博客网 时间:2024/05/19 19:56
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

" 自定义缩写

function! Eatchar(pat)
    let s:c = nr2char(getchar())
    return (s:c =~ a:pat) ? '' : s:c
endfunction
 


" C 文件头注释
iab     /**         /<Esc>75a*<Esc>o<Esc>0c$ * <Esc>yyADescription:<Esc>pmxpAAuthor  : wplxb<Esc>pALanguage: C<Esc>pADate    : <C-R>=strftime("%Y-%m-%d")<CR><Esc>p$r/74i*<Esc>0vyo<Esc>`x$9pa

" C 注释
iab     ///         /* <Esc>mxa */<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     ***         /*<Esc>yyppr A/<Esc>k0r A <C-R>=Eatchar('/s')<CR>

" C 预处理
iab     #i          #include <<Esc>mxa><Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     #d          #define

" C 关键字
iab     if(         if (<Esc>mxa)<CR>{<CR>}<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     el{         else<CR>{<Esc>mxa<CR>}<Esc>`xa<CR><C-R>=Eatchar('/s')<CR>
iab     ie(         if (<Esc>mxa)<CR>{<CR>}<CR>else<CR>{<CR>}<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     fo(         for (<Esc>mxa; ; )<CR>{<CR>}<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     fi(         for (i = 0; i < <Esc>mxa; ++i)<CR>{<CR>}<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     fi1(        for (i = 1; i <= <Esc>mxa; ++i)<CR>{<CR>}<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     fj(         for (j = 0; j < <Esc>mxa; ++j)<CR>{<CR>}<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     fj1(        for (j = 1; j <= <Esc>mxa; ++j)<CR>{<CR>}<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     ma(         int main(int argc, char * argv[])<CR>{<Esc>mxa<CR>}<Esc>`xa<CR><CR>return 0;<Esc>`xa<CR><C-R>=Eatchar('/s')<CR>
iab     wh(         while (<Esc>mxa)<CR>{<CR>}<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     sw(         switch (<Esc>mxa)<CR>{<CR>case <Esc>mya<CR>break;<CR>case <Esc>mza<CR>break;:<Esc>xa<CR>}<Esc>`yp`zp`xa<C-R>=Eatchar('/s')<CR>
iab     sd(         switch (<Esc>mxa)<CR>{<CR>case <Esc>mya<CR>break;<CR>case <Esc>mza<CR>break;<CR>default:<Esc>vya<CR>}<Esc>`yp`zp`xa<C-R>=Eatchar('/s')<CR>

" C 常用库函数
iab     sc(         scanf("<Esc>mxa", );<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     fs(         fscanf(<Esc>mxa, "", );<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     ss(         sscanf(<Esc>mxa, "", );<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     pr(         printf("<Esc>mxa", );<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     prn(        printf("<Esc>mxa/n");<Esc>`x<C-R>=Eatchar('/s')<CR>
iab     fp(         fprintf(<Esc>mxa, "", );<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     sp(         sprintf(<Esc>mxa, "", );<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     cpy(        strcpy(<Esc>mxa, );<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     cat(        strcat(<Esc>mxa, );<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     len(        strlen(<Esc>mxa);<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     cmp(        strcmp(<Esc>mxa, );<Esc>`xa<C-R>=Eatchar('/s')<CR>
iab     qs(         qsort(<Esc>mxa, , , );<Esc>`xa<C-R>=Eatchar('/s')<CR>

iab     ---         <Esc>75A-<Esc>a<C-R>=Eatchar('/s')<CR>


""""""""""""""""""""""""""""""""""
set mouse=a
colorscheme morning
set autochdir
set backspace=indent,eol,start
set ignorecase smartcase
set incsearch
set noignorecase
set showcmd

syntax on
"""""""""""""""""""""""""""""""""

"no backup
set nobackup

" 使用 murphy 调色板
"colo murphy
" 设置用于GUI图形用户界面的字体列表。
set guifont=Courier/ New
"
set nocompatible
" 设定文件浏览器目录为当前目录
set bsdir=buffer
set autochdir
" 设置编码
"set enc=utf-8
" 设置文件编码
"set fenc=utf-8
" 设置文件编码检测类型及支持格式
"set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
" 指定菜单语言
set langmenu=zh_CN.UTF-8
"source $VIMRUNTIME/delmenu.vim
"source $VIMRUNTIME/menu.vim
" 设置语法高亮度
set syn=c
"显示行号
set nu!
" 查找结果高亮度显示
set hlsearch
" tab宽度
set tabstop=4
set cindent shiftwidth=4
set autoindent shiftwidth=4
" C/C++注释
set comments=://
" 修正自动C式样注释功能 <2005/07/16>
set comments=s1:/*,mb:*,ex0:/
" 增强检索功能
set tags=./tags,./../tags,./**/tags
" 保存文件格式
set fileformats=dos,unix
" 键盘操作
map <Up> gk
map <Down> gj
" 命令行高度
set cmdheight=1
" 中文帮助
if version > 603
set helplang=cn
endi
"

"

"

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

  let eq = ''

  if $VIMRUNTIME =~ ' '

    if &sh =~ '/<cmd'

      let cmd = '""' . $VIMRUNTIME . '/diff"'

      let eq = '"'

    else

      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '/diff"'

    endif

  else

    let cmd = $VIMRUNTIME . '/diff'

  endif

  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq

endfunction

"

 
原创粉丝点击