" Gnouvea's Vimrc " Maintainer: Gnouveau <cuimingyucn@gmail.com> " Last update: 2011/2/16 " " 关闭vi兼容模式 set nocompatible " 让Backspace键在遇到indent/eol/start时可以正常回格 set backspace=indent,eol,start set nobackup " 不使用后缀为~的备份 "set noswapfile " 不使用swp文件 set history=50 " 最多记录50行历史命令 set ruler " 一直显示标尺 set cmdheight=1 " 设置命令行高度为1 set laststatus=2 " 总是显示状态行 set showcmd " 显示正在输入的命令 set nu "显示行号 set noeb "去掉错误提示音 set confirm "处理只读文件时弹出确认 set showmatch " 高亮显示匹配的括号 set scrolloff=2 " 光标移动到窗口顶部和底部时保持3行距离 " 搜索 set incsearch set ignorecase " 搜索时忽略大小写 " 允许使用鼠标 if has('mouse') set mouse=a endif " 使用gvim或终端有颜色时,打开语法高亮与搜索结果高亮 if &t_Co >2 || has("gui_running") syntax on set hlsearch endif " gvim中的设置 if has("gui_running") set guifont=YaHei_Mono:h12 " 字体设置 set guioptions-=T " 去工具条 set guioptions-=m " 去菜单 colorscheme lucius " 配色 endif " 当前系统支持自动命令autocmd时 if has("autocmd") " 开启自动文件类型体测,并开启对应缩进 filetype plugin indent on " Put these in an autocmd group, so that we can delete them easily. augroup vimrcEx au! " 设置text文档每行最多为78个字符,超过78个自动换行 autocmd FileType text setlocal textwidth=78 " 打开文件时跳转到上次编辑的位置 autocmd BufReadPost * / if line("'/"") > 1 && line("'/"") <= line("$") | / exe "normal! g`/"" | / endif augroup END else set autoindent " always set autoindenting on endif " has("autocmd") " Convenient command to see the difference between the current buffer and the " file it was loaded from, thus the changes you made. " Only define it when not defined already. if !exists(":DiffOrig") command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis / | wincmd p | diffthis endif " 编码设置 set encoding=utf-8 set termencoding=utf-8 set formatoptions+=mM set fencs=utf-8,gbk if v:lang =~? '^/(zh/)/|/(ja/)/|/(ko/)' set ambiwidth=double endif if has("win32") source $VIMRUNTIME/mswin.vim source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim behave mswin " 鼠标使用Windows标准 language messages zh_CN.utf-8 endif " Tab键设置 set tabstop=4 set softtabstop=4 set shiftwidth=4 set smarttab " 允许backspace和光标键跨越行边界 set whichwrap+=<,>,h,l " 带有如下符号的单词不要被换行分割 set iskeyword+=_,$,@,%,#,- " 状态行内容 set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%] " 自动完成括号及引号 inoremap ( ()<ESC>i inoremap " ""<ESC>i inoremap ' ''<ESC>i inoremap { {}<ESC>i inoremap [ []<ESC>i inoremap ) <c-r>=ClosePair(')')<CR> inoremap } <c-r>=ClosePair('}')<CR> inoremap ] <c-r>=ClosePair(']')<CR> function! ClosePair(char) if getline('.')[col('.') - 1] == a:char return "/<Right>" else return a:char endif endf " 键盘映射 " 垂直分隔窗口vsplit -> vs nmap vs :vsplit " : -> <space> nmap <space> : """""""""""""""""""""""""""""""""""""" " Taglist """""""""""""""""""""""""""""""""""""" map <F3> :silent! Tlist<CR> let Tlist_Show_One_File = 0 "只显示当前文件tags let Tlist_File_Fold_Auto_Close = 0 "非当前文件函数列表隐藏 let Tlist_Exit_OnlyWindow = 1 "若taglist窗口为最后一个窗口,则退出 let Tlist_Use_Right_Window = 1 "在右侧显示taglist窗口 let Tlist_Use_SingleClick = 1 "单击跳转 let Tlist_Auto_Open = 0 "自动打开Taglist窗口 let Tlist_Process_File_Always=1 "无论taglist窗口有没有打开,始终解析文件中的tag