Linux环境写到用户主目录下的.vimrc文件(没有则新建),Windows环境则为GVim安装目录下的_vimrc(没有则新建),内容如下:
"分上下两屏
"sp "分左右两屏
"vs "显示行号
set number "显示命令
set showcmd "突出显示当前行
set cursorline "在显示当前模式
set showmode "空格键映射成“:”
nmap <space> : "打开语法高亮
syn on
syntax enable "tab键占4个字符
set smarttab
set expandtab
set tabstop=4
set shiftwidth=4 "隐藏菜单栏
set guioptions-=m "隐藏工具栏
set guioptions-=T "去掉欢迎界面
"set shortmess=atI "在右下角显示光标所在的行数等信息
set ruler "当文件在外部被修改时,自动重新读取
set autoread "可以在没有保存的情况下切换buffer
"set hid "增强模式中的命令行自动完成操作
set wildmenu "在所有模式下都允许使用鼠标,还可以是n,v,i,c等
set mouse=n "文件类型检测 此命令相当于:filetype on 、filetype plugin on 、filetype indent on 三条命令
filetype plugin indent on "关闭兼容模式 compatible,若启用兼容模式,则某些自定义的选项将失效。去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
set nocompatible "退格键和方向键可以换行
set whichwrap+=<,>,h,l "增量式搜索
set incsearch "高亮搜索 nohlsearch
set hlsearch "搜索时忽略大小写
set ignorecase "设置魔术 大有用处:与正则表达式相关
set magic "显示匹配的括号
set showmatch "关闭备份
set nobackup "与上一起,用于关闭备份
set nowb "vim记住的历史操作的数量,默认的是20
set history=999 "不使用swp文件,注意,错误退出后无法恢复
set noswapfile "在breakat字符处而不是最后一个字符处断行
set lbr "恢复上次文件打开位置
set viminfo='10,\"100,:20,%,n~/.viminfo "设置光标形状为"|"
set gcr=n-v-c:ver25-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor "显示状态栏
set laststatus=0
highlight StatusLine ctermfg=blue ctermbg=white "GUI行号颜色
highlight LineNr guifg=gray
highlight LineNr guibg=white "控制台下行号颜色
highlight LineNr ctermfg=gray
highlight LineNr ctermbg=NONE "高亮显示
"set hlsearch
set nohlsearch "不高亮显示 "行高亮
set cursorline
hi CursorLine cterm=bold guibg=#EAF4FF
"hi CursorLine cterm=none ctermbg=blue ctermfg=none guibg=LightBlue guifg=none "列高亮
"set cursorcolumn
"hi CursorColumn cterm=none ctermbg=white ctermfg=blue guibg=lightblue guifg=none "设置字符编码
set encoding=utf8
set fileencodings=utf8,gb2312,gb18030,ucs-bom,latin1 "字体设置
if(has("gui_running"))
set guifont=Source\ Code\ Pro\ 11
endif "设置Right margin
"set colorcolumn=99
highlight colorcolumn ctermbg=255 guibg=#FAFCFF
set colorcolumn=99
let &colorcolumn=join(range(99,999),",") "若用了:set indent,:set ai 等自动缩进,想用退格键将字段缩进的删掉,必须设置这个选项。否则不响应。
set backspace=eol,start,indent "自动缩进 或者 set ai
set autoindent "智能缩进 或者 set si
set smartindent "设置CC++风格方式来处理程序的缩进结构
set cindent "C语言注释为灰色(置于最后)
hi Comment ctermfg=gray
hi Comment guifg=gray "vim 控制台cterm、ctermbg、ctermfg可选颜色代码
"烟灰色: 255
"淡紫色: 189
"淡紫色: 225
"浅蓝紫色: 153
"品红: 224
"蓝色: 117
"淡天蓝色: 195
"绿色: 49
"浅黛绿色: 152
"浅嫩绿色: 194
"蛋黄色: 223
"浅黄色: 230
"Black
"DarkBlue
"DarkGreen
"DarkCyan
"DarkRed
"DarkMagenta
"Brown, DarkYellow
"LightGray, LightGrey, Gray, Grey
"DarkGray, DarkGrey
"Blue, LightBlue
"Green, LightGreen
"Cyan, LightCyan
"Red, LightRed
"Magenta, LightMagenta
"Yellow, LightYellow
"White
OK哒~