我的GVIM配置文件

以下是我自己的vim配置文件。个人建议,还是使用完整的命令比较好,这样有助于理解记忆,尤其对于初次接触的人来说更重要。
set number "显示行号,取消显示行号为nonumber,诸多进行相反设置都是加前缀no即可
set numberwidth=3 "设置用于显示行号的宽度
set ruler "在下方显示标尺
set encoding=utf8
set hlsearch "搜索后,高亮
set incsearch "搜索时,没有回车就高亮
set ignorecase "搜索时,忽略大小写
set showmatch
set guioptions= "隐藏菜单栏
set autochdir "自动将当前目录切换为编辑文件所在的目录
set nocursorcolumn "高亮当前列
set cursorline "高亮当前行
"窗口打开后自动最大化,这是对于gvim有效的
autocmd guienter * simalt ~x
set nowrap"不自动换行
set autoread
set nocompatible "取消对vim、的兼容,这样可以使用到vim的一些特性
set guioptions+=r "显示右侧的滚动条
set guioptions+=b "显示底部的滚动条
set scrolloff=3 "使光标始终和上下边缘相距3行
set smartindent "回车后,根据上一行自动缩进
set smarttab
set backup "设置备份
set nobackup
syntax on "打开语法高亮
set foldenable
set foldmarker={,}
set foldmethod=marker
nnoremap <space> @=((foldclosed(line('.'))<0)?'zc':'zo')<CR>
set foldopen+=search
set foldopen+=undo
set foldlevel=1
set foldcolumn=4
filetype plugin on
highlight normal guifg=#008000 guibg=#000000
"set visualbell t_vb=
"以下是对一些经常用到的命令映射的快捷键
nmap <silent> <F1> :w<cr>
nmap <silent> <F2> :q<cr>
nmap <silent> <F3> :x<cr>
set readonly 设置只读
set nomodifiable 设置为不可修改模式
digraphs 显示编码表
changes 打开更改列表
gf 打开以当前字符的文件
ga 显示当前光标下单个字的ascii,十进制,十六进制……
:browse e 打开文件选择框
tabe file 在新的tab中打开文件file
<C-A>,<C-X> 增加,减少当前光标下的数字
:bn 跳转到下一个buffer :bp  跳转到前一个buffer :wn 保存当前buffer并跳转到下一个buffer (超有用) :wp 保存当前buffer并跳转到前一个buffer :bd 把当前文件从buffer移出 (超有用)
  • 配置文件[codesyntax lang="php" lines="normal"]
    scriptencoding=utf-8
    
    set number
    set incsearch
    set hlsearch
    set autoindent
    "set smartindent
    set autochdir
    set ignorecase
    "set textwidth=80
    set colorcolumn=+1
    set tabstop=4
    set shiftwidth=4
    set backspace=indent,start,eol
    set showmatch
    set matchtime=1
    set ruler
    set foldmethod=syntax
    "set foldmethod=indent
    set foldlevel=0
    set encoding=utf-8
    set termencoding=utf-8
    set langmenu=zh_CN.utf-8
    
    language message zh_CN.utf-8
    
    "set titlestring=中文
    
    set nolist
    set nocursorline
    set nocursorcolumn
    
    syntax on
    filetype on
    
    map		<special> <silent> <F1> :call Quit()<CR>" ---Quit
    map		<special> <silent> <F2> :call ContentReload()<CR>" ---Quit
    map		<special> <silent> <F3> :call OpenShell()<CR>" ---Shell
    map		<special> <silent> <F4> :call OpenTaskMgr()<CR>" ---TaskMgr
    map		<F5> :call Test()<CR>" ---Test
    map		<special> <silent> <F6> :call ReloadFile()<CR>" ---ReloadFile
    map		<special> <silent> <F10> :call ReloadRc()<CR>" ---Reload RcFile
    map		<special> <silent> <F11> :call ToggleFullScreen()<CR>" ---FullScreen
    map		<special> <silent> <F12> :call EditRc()<CR>" ---Edit RcFile
    
    if has("gui")
    	map <special> <silent> <C-K> :call RestoreWin()<CR>" ---Restore
    	map <special> <silent> <C-M> :call MaxWin()<CR>" ---Maximize
    	map <special> <silent> <C-N> :call MinWin()<CR>" ---Minimize
    endif
    
    map		<special> <silent> <C-S> :call Save()<CR>" ---Save
    map		<special> <silent> <C-Tab> :call SwitchWin()<CR>" ---SwitchWin
    
    imap	<special> <silent> <C-S> <ESC>:write<CR>a
    imap	<special> <silent> <C-Tab> <ESC><C-W><C-W>a
    
    function! EditRc()
    	if "" == expand("%:p")
    		:edit ~/.vimrc
    	elseif ".vimrc" != expand("%:t")
    		:split ~/.vimrc
    	endif
    endfunction
    
    function! Test()
    	let s:buf_name = "suren"
    
    	if !bufexists(s:buf_name) || bufwinnr(s:buf_name) == -1
    		25vsplit suren
    
    		set modifiable
    		set buftype=nofile
    
    		redir @a
    		silent map
    		redir END
    
    		silent execute "normal " . '"ap'
    		silent :%substitute/^\n// 
    		silent :global!/\s*:call.*---/delete 
    		silent :%substitute/\s*:call.*---/\t/
    		silent :%substitute/^\s*//
    		silent :nohlsearch
    		sort
    
    		set nowrap
    		set colorcolumn=""
    		set readonly
    		set nomodifiable
    	endif
    endfunction
    
    function! SubString(str, begin, len)
    	let str=a:str
    	let begin=a:begin
    	let len=a:len
    	let length=begin+len
    	let rv=""
    
    	while begin < length
    		let rv=rv.str[begin]
    
    		let begin=begin+1
    	endwhile
    
    	return rv
    endfunction
    
    function! IndexOf(str, sub)
    	let str=a:str
    	let sub=a:sub
    	let subLen=strlen(sub)
    	let len=strlen(str)
    	let len=len-subLen+1
    	let i=0
    
    	while i < len
    		if SubString(str, i, subLen) == sub
    			return i
    		endif
    
    		let i=i+1
    	endwhile
    
    	return -1
    endfunction
    
    function! LastIndexOf(str, sub)
    	let str=a:str
    	let sub=a:sub
    	let len=strlen(str)
    	let subLen=strlen(sub)
    	let i=len-subLen
    
    	while i >= 0
    		if SubString(str, i,subLen) == sub
    			return i
    		endif
    
    		let i=i-1
    	endwhile
    
    	return -1
    endfunction
    
    function! SortFunc(x, y)
    	let s:index = 0
    	let s:x_list = split(a:x)
    	let s:y_list = split(a:y)
    	let s:x_len = len(s:x_list)
    	let s:y_len = len(s:y_list)
    	let s:x_is_num = 0
    	let s:y_is_num = 0
    
    	if s:x_list == s:y_list
    		return 0
    	elseif s:x_len == 0
    		return -1
    	elseif s:y_len == 0
    		return 1
    	endif
    
    	for i in s:x_list
    		let s:x = i
    		let s:y = s:y_list[s:index]
    		let s:x_is_num = s:x + 0
    		let s:y_is_num = s:y + 0
    
    		if s:x_is_num != 0
    			let s:x = s:x_is_num
    		endif
    
    		if s:y_is_num != 0
    			let s:y = s:y_is_num
    		endif
    
    		if s:x > s:y
    			return 1
    		endif
    
    		if s:x < s:y
    			return -1
    		endif
    
    		let s:index = s:index + 1
    
    		if s:index >= s:y_len
    			break
    		endif
    	endfor
    
    	return 0
    endfunction
    
    function! Sort(from, to)
    	let s:begin = a:from + 0
    	let s:end = a:to + 0
    
    	if s:begin <= 0
    		let s:begin = 1
    	endif
    
    	if s:end <= 0
    		let s:end = 1
    	endif
    
    	if s:begin > line("$") || s:end > line("$")
    		return
    	endif
    
    	let s:content = getline(s:begin, s:end)
    	let s:content = sort(s:content, "SortFunc")
    
    	call DeleteLine(s:begin, s:end)
    	call append(s:begin - 1, s:content)
    	$delete
    endfunction
    
    function! DeleteLine(from, to)
    	let s:begin = a:from + 0
    	let s:end = a:to + 0
    
    	if s:begin < 0 || s:begin > line("$")
    		return
    	endif
    
    	if s:end < 0 || s:end > line("$")
    		return
    	endif
    
    	execute "normal " . s:begin . "gg"
    	execute ":" . s:begin . "," . s:end . "delete"
    endfunction
    
    function! Quit()
    	silent :quit
    endfunction
    
    function! ContentReload()
    	silent :e
    	execute "normal G"
    endfunction
    
    function! OpenShell()
    	if has("gui_win32")
    		silent execute "!start cmd"
    	endif
    endfunction
    
    function! OpenTaskMgr()
    	if has("gui_win32")
    		silent execute "!start taskmgr"
    	endif
    endfunction
    
    if !exists("*ReloadRc")
    	function! ReloadRc()
    		silent :source ~/.vimrc
    	endfunction
    endif
    
    if !exists("*ReloadFile")
    	function! ReloadFile()
    		silent :e
    		execute "normal " . s:begin . "G"
    	endfunction
    endif
    
    function! SwapMouse()
    	let s:suren_lib = findfile("suren.dll", &runtimepath)
    
    	if s:suren_lib != ""
    		call libcall(s:suren_lib, "SwapMouse", "")
    	endif
    endfunction
    
    function! ToggleFullScreen()
    	let s:suren_lib_str = "suren.dll"
    	let s:suren_lib = findfile(s:suren_lib_str, &runtimepath)
    
    	if !exists("s:suren_fullscreen")
    		let s:suren_fullscreen = 0
    	endif
    
    	if s:suren_lib != ""
    		let s:suren_lib = s:suren_lib_str
    
    		if s:suren_fullscreen == 0
    			echo s:suren_lib
    			let s:suren_win_info =  libcall(s:suren_lib, "FullScreen", "")
    
    			if len(split(s:suren_win_info)) == 4
    				let s:suren_win_last_left = split(s:suren_win_info)[0] + 0
    				let s:suren_win_last_top = split(s:suren_win_info)[1] + 0
    				let s:suren_win_last_right = split(s:suren_win_info)[2] + 0
    				let s:suren_win_last_bottom = split(s:suren_win_info)[3] + 0
    
    				set guioptions-=m
    				set guioptions-=T
    
    				let s:suren_fullscreen = 1
    			endif
    		else
    			call libcall(s:suren_lib, "FullScreen", "")
    
    			call libcall(s:suren_lib, "SetPosX", s:suren_win_last_left)
    			call libcall(s:suren_lib, "SetPosY", s:suren_win_last_top)
    			call libcall(s:suren_lib, "SetWinWidth",
    				\ s:suren_win_last_right - s:suren_win_last_left)
    			call libcall(s:suren_lib, "SetWinHeight",
    				\ s:suren_win_last_bottom - s:suren_win_last_top)
    
    			set guioptions+=m
    			set guioptions+=T
    
    			let s:suren_fullscreen = 0
    		endif
    	else
    		echo "can't found " . s:suren_lib_str
    	endif
    endfunction
    
    function! MaxWin()
    	simalt ~x
    endfunction
    
    function! MinWin()
    	simalt ~n
    endfunction
    
    function! RestoreWin()
    	simalt ~r
    endfunction
    
    function! SwitchWin()
    	execute "normal \<C-W>\<C-W>"
    endfunction
    
    function! Save()
    	let s:path = expand("%:p")
    	
    	if s:path == ""
    		if has("gui")
    			execute ":browse confirm saveas"
    		else
    			let s:path = input("saveas:")
    			execute ":write " . s:path
    		endif
    	else
    		execute ":write"
    	endif
    endfunction
    [/codesyntax]

你可能感兴趣的:(vim,配置文件,gvim,vimrc)