windows下常用的_vimrc配置

效果图

配置 

set nocompatible	"set compatible让 vim 关闭所有扩展的功能,尽量模拟 vi 的行为但这样就不应用 vim 的很多强大功能,所以一般没有什么特殊需度要的话(比如执行很老的 vi 脚本),都要在 vim 的配置开始,写上 set nocompatible,关闭兼容模式。由于这个选项是最最基础的选项,会连带很多其它选项发生变动(称作副作用),所以它必需是第一个设定的选项。
set imcmdline

"gvim内部编码
set encoding=utf8
set langmenu=zh_CN.utf-8
language message zh_CN.UTF-8	"解决Console输出乱码

set termencoding=utf-8
"当前编辑的文件编码
set fileencoding=chinese
"gvim打开支持编码的文件
set fileencodings=ucs-bom,utf-8,chinese

"解决菜单乱码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim

"引用一些默认配置
source $VIMRUNTIME/vimrc_example.vim

"模仿win快捷键,如:Ctrl+A全选、Ctrl+c复制、Ctrl+v粘贴等等
"source $VIMRUNTIME/mswin.vim
"behave mswin
" Vim 的默认寄存器和系统剪贴板共享
set clipboard+=unnamed
"自动最大化
"au GUIEnter * simalt ~x
"设置字体和字号
set guifont=Courier_New:b:h18:w9.5
set guifontwide=NSimSun:b:h18	"新宋体
"配色方案
colors notepad-plus-plus

"防止特殊符号无法正常显示
set ambiwidth=double

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

"Persistent undo
if has ('persistent_undo')
	set undodir=~/.vim/undodir
	set undofile
	set undolevels=1000 “maximum number of changes that can be undone
	set undoreload=10000 “maximum number lines to save for undo on a buffer reload
endif

"撤销列表
"undo list
"自动隐藏没有保存的缓冲区,切换buffer时不给出保存当前buffer的提示
set hidden

"在.vim/syntax/c.vim文件中设置了运算符,函数名等高亮后,可以:
"syntax enable            "打开语法高亮
syntax on                "打开语法高亮

"开启自动缩进
set autoindent
set smartindent
set cindent

"Tab转换成Space
"set expandtab
set noexpandtab
"将Tab解析为4个空白
set tabstop=4
"Tab宽度
set shiftwidth=4
"按一次backspace就删除4个空格,仅仅在前面没有字符的情况起作用
set smarttab

"大小写匹配
set ignorecase smartcase
"modeline可以让你针对每个文件进行文件级别的设置,这些设置是覆盖当前用户的vimrc中的设置的。当vim打开一个包含了vim modeline注释行的文件时,会自动读取这一行的参数配置并调整自己的设置到这个配置。
set modeline

"工具栏和菜单栏
set guioptions+=T
set guioptions+=m
"右侧滚动条
set guioptions-=r

"set nowrap	"关闭自动换行
set wrap
set linebreak            "整词换行,与自动换行搭配使用,效果很好
set backspace=indent,eol,start	"支持BackSpace

"状态栏
set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%]    "显示文件名: 总行数, 总的字符数
set ruler		 "在编辑过程中, 在右下角显示光标位置的状态行

set showmatch	"显示匹配
set noswapfile

"不保留备份文件,但写入期间有备份
set writebackup
set nobackup
set noswapfile	"缓冲区使用交换文件

set hlsearch	"搜索高亮
set incsearch	"打开显示查找匹配过程
set wrapscan	"搜索绕回
set nu		"行号
set scrolloff=5         "在光标接近底端或顶端时,自动下滚或上滚
set autochdir            "自动设置当前目录为正在编辑的目录

"可以把需要开启的键的代号写到 whichwrap 的参数列表中, 各个键之间使用逗号分隔。
"以下是 whichwrap 支持的按键名称列表:
"b: 在 Normal 或 Visual 模式下按 除(Backspace)键。 s: 在 Normal 或 Visual 模式下按空 键。 h: 在 Normal 或 Visual 模式下按 h 键。 l: 在 Normal 或 Visual 模式下按 l 键。 <: 在 Normal 或 Visual 模式下按左方向键。 >: 在 Normal 或 Visual 模式下按右方向键。 ~: 在 Normal 模式下按 ~ 键(翻转当前字母大小写)。 [: 在 Insert 或 Replace 模式下按左方向键。 ]: 在 Insert 或 Replace 模式下按右方向键。
set whichwrap=b,s,h,l,<,>,[,]    "光标可以从行首和行尾跳到另一行去

map <MiddleMouse> <Nop>
imap <MiddleMouse> <Nop>
map <2-MiddleMouse> <Nop>
imap <2-MiddleMouse> <Nop>
map <3-MiddleMouse> <Nop>
imap <3-MiddleMouse> <Nop>
map <4-MiddleMouse> <Nop>
imap <4-MiddleMouse> <Nop>

set tags=tags;

set mouse=a
set autowriteall
set cino=g1h1i2:0
run cscope.vim

hi Normal guibg=#CBE8CA

map <C-g> :BufExplorer<CR>
let g:bufExplorerDefaultHelp=0
let g:bufExplorerShowRelativePath=1

autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
au FileType c,cc,cpp,h setlocal comments-=:// comments+=f://

autocmd FileType c,cc,cpp,h,js,lua,java set expandtab | set shiftwidth=4

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章