source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
colorscheme desert
filetype indent on
filetype plugin on
filetype plugin indent on
set nocompatible
set tabstop=4set shiftwidth=4
set backspace=2
set showmatch
set mouse=a
set hlsearch
set nocompatible
set guifont=Consolas:h16
set syntax=on
syntax enable
set encoding=utf-8
set termencoding=utf-8
set ai!
set nu
set ruler
set hidden
set list
set nobackup
set autochdir
" 设置编码
set fenc=utf-8
set encoding=utf-8
set fileencodings=utf-8,chinese,latin-1
if has("win32")
set fileencoding=chinese
else
set fileencoding=utf-8
endif
"解决中文菜单乱码
set langmenu=zh_CN.utf-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"解决console输出乱码
language messages zh_cn.utf-8
au BufRead,BufNewFile *.js set syntax=jquery "添加jquery配色支持
let b:javascript_fold=1 " 打开javascript折叠
let javascript_enable_domhtmlcss=1 " 打开javascript对dom、html
"这是我偷来的文件,
" ======= 引号 && 括号自动匹配 ======= "
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i
:inoremap ` ``<ESC>i
function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
" ESC + H Normal模式下开启Devhelp查询功能
function! DevHelpCurrentWord()
let word = expand("<cword>")
exe "!devhelp -s " . word . " &"
endfunction
nmap <esc>h :call DevHelpCurrentWord()<CR>
" MiniBufExplorer 多个文件切换 可使用鼠标双击相应文件名进行切换
let g:miniBufExplMapWindowNavVim=1
let g:miniBufExplMapWindowNavArrows=1
let g:miniBufExplMapCTabSwitchBufs=1
let g:miniBufExplModSelTarget=1
" :Tlist 调用TagList
let Tlist_Show_One_File=1 " 只显示当前文件的tags
let Tlist_Exit_OnlyWindow=1 " 如果Taglist窗口是最后一个窗口则退出Vim
let Tlist_Use_Right_Window=1 " 在右侧窗口中显示
let Tlist_File_Fold_Auto_Close=1 " 自动折叠
" :LoadTemplate 根据文件类型自动加载模板
let g:template_path='~/.vim/template/'
" snipMate Tab智能补全
let g:snips_author='Ruchee'
" :AuthorInfoDetect 自动添加作者、时间等信息,本质是NERD_commenter && authorinfo的结合
let g:vimrc_author='Ruchee'
let g:vimrc_email='my@ruchee.com'
let g:vimrc_homepage='http://www.ruchee.com'
" Ctrl + H 将光标移到当前行的行首
imap <c-h> <ESC>I
" Ctrl + J 将光标移到下一行的行首
imap <c-j> <ESC>jI
" Ctrl + K 将光标移到上一行的末尾
imap <c-k> <ESC>kA
" Ctrl + L 将光标移到当前行的行尾
imap <c-l> <ESC>A
" Ctrl + E 一步加载语法模板和作者、时间信息
map <c-e> <ESC>:LoadTemplate<CR><ESC>:AuthorInfoDetect<CR><ESC>Gi
imap <c-e> <ESC>:LoadTemplate<CR><ESC>:AuthorInfoDetect<CR><ESC>Gi
vmap <c-e> <ESC>:LoadTemplate<CR><ESC>:AuthorInfoDetect<CR><ESC>Gi
" jj 保存当前文件并留在插入模式 [插入模式]
imap jj <ESC>:w<CR>li
" kk 返回Normal模式,不执行保存 [插入模式]
imap kk <ESC>l
" nt 打开NERDTree窗口,在左侧栏显示 [非插入模式]
map nt :NERDTree<CR>
" tl 打开Taglist窗口,在右侧栏显示 [非插入模式]
map tl :Tlist<CR><c-l>
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