文档章节

我的GVIM配置文件

素人派
 素人派
发布于 2016/12/31 20:49
字数 1508
阅读 9
收藏 0
以下是我自己的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]

本文转载自:http://surenpi.com/2014/10/30/%e6%88%91%e7%9a%84gvim%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6/

素人派
粉丝 26
博文 1907
码字总数 10223
作品 6
东城
程序员
私信 提问

暂无文章

最简单的获取相机拍照的图片

  import android.content.Intent;import android.graphics.Bitmap;import android.os.Bundle;import android.os.Environment;import android.provider.MediaStore;import andr......

MrLins
25分钟前
2
0
说好不哭!数据可视化深度干货,前端开发下一个涨薪点在这里~

随着互联网在各行各业的影响不断深入,数据规模越来越大,各企业也越来越重视数据的价值。作为一家专业的数据智能公司,个推从消息推送服务起家,经过多年的持续耕耘,积累沉淀了海量数据,在...

个推
27分钟前
5
0
第三方支付-返回与回调注意事项

不管是支付宝,微信,还是其它第三方支付,第四方支付,支付机构服务商只要涉及到钱的交易都要进行如下校验,全部成功了才视为成功订单 1.http请求是否成功 2.校验商户号 3.校验订单号及状态...

Shingfi
29分钟前
3
0
简述Java内存分配和回收策略以及Minor GC 和 Major GC(Full GC)

内存分配: 1. 栈区:栈可分为Java虚拟机和本地方法栈 2. 堆区:堆被所有线程共享,在虚拟机启动时创建,是唯一的目的是存放对象实例,是gc的主要区域。通常可分为两个区块年轻代和年老代。更...

DustinChan
35分钟前
4
0
Excel插入批注:可在批注插入文字、形状、图片

1.批注一直显示:审阅选项卡-------->勾选显示批注选项: 2.插入批注快捷键:Shift+F2 组合键 3.在批注中插入图片:鼠标右键点击批注框的小圆点【重点不可以在批注文本框内点击】----->调出批...

东方墨天
59分钟前
6
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部