vimrc的存放位置:
系统 vimrc 文件: "$VIM/vimrc"
用户 vimrc 文件: "$HOME/.vimrc"
用户 exrc 文件: "$HOME/.exrc"
系统 gvimrc 文件: "$VIM/gvimrc"
用户 gvimrc 文件: "$HOME/.gvimrc"
系统菜单文件: "$VIMRUNTIME/menu.vim"
$VIM 预设值: "/usr/share/vim"
vimrc文件内容:
"是否兼容VI,compatible为兼容,nocompatible为不完全兼容
"如果设置为compatible,则tab将不会变成空格
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
"设置鼠标运行模式为WINDOWS模式
behave mswin
" Multi-encoding setting, MUST BE IN THE BEGINNING OF .vimrc!
"
if has("multi_byte")
" When 'fileencodings' starts with 'ucs-bom', don't do this manually
"set bomb
set fileencodings=ucs-bom,utf-8,chinese,taiwan,japan,korea,latin1
" CJK environment detection and corresponding setting
if v:lang =~ "^zh_CN"
" Simplified Chinese, on Unix euc-cn, on MS-Windows cp936
set encoding=chinese
set termencoding=chinese
if &fileencoding == ''
set fileencoding=chinese
endif
elseif v:lang =~ "^zh_TW"
" Traditional Chinese, on Unix euc-tw, on MS-Windows cp950
set encoding=taiwan
set termencoding=taiwan
if &fileencoding == ''
set fileencoding=taiwan
endif
elseif v:lang =~ "^ja_JP"
" Japanese, on Unix euc-jp, on MS-Windows cp932
set encoding=japan
set termencoding=japan
if &fileencoding == ''
set fileencoding=japan
endif
elseif v:lang =~ "^ko"
" Korean on Unix euc-kr, on MS-Windows cp949
set encoding=korea
set termencoding=korea
if &fileencoding == ''
set fileencoding=korea
endif
endif
" Detect UTF-8 locale, and override CJK setting if needed
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set encoding=utf-8
endif
else
echoerr 'Sorry, this version of (g)Vim was not compiled with "multi_byte"'
endif
"解决菜单乱码
set encoding=utf-8
"fileencodings需要注意顺序,前面的字符集应该比后面的字符集大
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set langmenu=zh_CN.utf-8
set imcmdline
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"解决consle输出乱码
language messages zh_CN.utf-8
"自动检测文件类型并加载相应的设置,snipMate插件需要打开这个配置选项
filetype plugin indent on
"语法高亮
syntax on
"自动缩进
set autoindent
"设置 Backspace 和 Delete 的灵活程度,backspace=2 则没有任何限制
"设置在哪些模式下使用鼠标功能,mouse=a 表示所有模式
set mouse=a
set backspace=2
"不自动换行
set nowrap
"设置超过100字符自动换行
"set textwidth=100
"设置超过100列的字符带下划线
"au BufWinEnter * let w:m2=matchadd('Underlined', '\%>100v.\+', -1)
"syn match out80 /\%80v./ containedin=ALL
"hi out80 guifg=white guibg=red
"智能对齐方式
set smartindent
"一个tab是4个字符
set tabstop=4
"按一次tab前进4个字符
set softtabstop=4
"用空格代替tab
set expandtab
"设置自动缩进
set ai!
"缩进的字符个数
set cindent shiftwidth=4
"set autoindent shiftwidth=2
"设置折叠模式
set foldcolumn=4
"光标遇到折叠,折叠就打开
"set foldopen=all
"移开折叠时自动关闭折叠
"set foldclose=all
"zf zo zc zd zr zm zR zM zn zi zN
"依缩进折叠
" manual 手工定义折叠
" indent 更多的缩进表示更高级别的折叠
" expr 用表达式来定义折叠
" syntax 用语法高亮来定义折叠
" diff 对没有更改的文本进行折叠
" marker 对文中的标志折叠
set foldmethod=syntax
"启动时不要自动折叠代码
set foldlevel=100
"依标记折叠
set foldmethod=marker
"显示行号
set number
"打开光标的行列位置显示功能
set ruler
"显示中文引号
set ambiwidth=double
"行高亮
set cursorline
"列高亮,与函数列表有冲突
set cursorcolumn
"设置命令行的高度
set cmdheight=2
"高亮搜索的关键字
set hlsearch
"搜索忽略大小写
set ignorecase
"设置命令历史行数
set history=100
"启动的时候不显示那个援助索马里儿童的提示
"set shortmess=atI
"不要闪烁
"set novisualbell
"显示TAB健
set list
set listchars=tab:>-,trail:-
"高亮字符,让其不受100列限制
":highlight OverLength ctermbg=red ctermfg=white guibg=grey guifg=white
":match OverLength '\%101v.*'
"设置VIM状态栏
set laststatus=2 "显示状态栏(默认值为1, 无法显示状态栏)
set statusline=
set statusline+=%2*%-3.3n%0*\ " buffer number
set statusline+=%f\ " file name
set statusline+=%h%1*%m%r%w%0* " flag
set statusline+=[
if v:version >= 600
set statusline+=%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{&fileencoding}, " encoding
endif
set statusline+=%{&fileformat}] " file format
set statusline+=%= " right align
"set statusline+=%2*0x%-8B\ " current char
set statusline+=0x%-8B\ " current char
set statusline+=%-14.(%l,%c%V%)\ %<%P " offset
if filereadable(expand("$VIM/vimfiles/plugin/vimbuddy.vim"))
set statusline+=\ %{VimBuddy()} " vim buddy
endif
"状态行颜色
"highlight StatusLine guifg=SlateBlue guibg=Yellow
"highlight StatusLineNC guifg=Gray guibg=White
"设置路径,多个路径用逗号分隔
set path=.,"E:/Web/htdocs",,
"去掉有关vi一致性模式,避免以前版本的一些bug和局限
set nocp
"增强模式中的命令行自动完成操作
set wildmenu
"执行 Vim 缺省提供的 .vimrc 文件的示例,包含了打开语法加亮显示等最常用的功能
source $VIMRUNTIME/vimrc_example.vim
"缺省不产生备份文件
set nobackup
"在输入括号时光标会短暂地跳到与之相匹配的括号处,不影响输入
set showmatch
"正确地处理中文字符的折行和拼接
set formatoptions+=mM
"设定文件浏览器目录为当前目录
set bsdir=buffer
"自动切换当前目录为当前文件所在的目录
set autochdir
"自动重新加载外部修改内容
"set autoread
"使PHP识别EOT字符串
hi link phpheredoc string
"允许在有未保存的修改时切换缓冲区
set hidden
"选中一段文字并全文搜索这段文字
vmap <silent> ,/ y/<C-R>=escape(@", '\\/.*$^~[]')<CR><CR>
vmap <silent> ,? y?<C-R>=escape(@", '\\/.*$^~[]')<CR><CR>
"进入当前编辑的文件的目录
autocmd BufEnter * exec "cd %:p:h"
"保存文件的格式顺序
set fileformats=dos,unix
"配色
"colorscheme peacock_light
colorscheme peacock_desert
温馨提示:内容为网友见解,仅供参考