我的GVIM配置文件

来源:互联网 发布:linux进去数据库命令 编辑:程序博客网 时间:2024/05/18 00:45
以下是我自己的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-8set numberset incsearchset hlsearchset autoindent"set smartindentset autochdirset ignorecase"set textwidth=80set colorcolumn=+1set tabstop=4set shiftwidth=4set backspace=indent,start,eolset showmatchset matchtime=1set rulerset foldmethod=syntax"set foldmethod=indentset foldlevel=0set encoding=utf-8set termencoding=utf-8set langmenu=zh_CN.utf-8language message zh_CN.utf-8"set titlestring=中文set nolistset nocursorlineset nocursorcolumnsyntax onfiletype onmap<special> <silent> <F1> :call Quit()<CR>" ---Quitmap<special> <silent> <F2> :call ContentReload()<CR>" ---Quitmap<special> <silent> <F3> :call OpenShell()<CR>" ---Shellmap<special> <silent> <F4> :call OpenTaskMgr()<CR>" ---TaskMgrmap<F5> :call Test()<CR>" ---Testmap<special> <silent> <F6> :call ReloadFile()<CR>" ---ReloadFilemap<special> <silent> <F10> :call ReloadRc()<CR>" ---Reload RcFilemap<special> <silent> <F11> :call ToggleFullScreen()<CR>" ---FullScreenmap<special> <silent> <F12> :call EditRc()<CR>" ---Edit RcFileif has("gui")map <special> <silent> <C-K> :call RestoreWin()<CR>" ---Restoremap <special> <silent> <C-M> :call MaxWin()<CR>" ---Maximizemap <special> <silent> <C-N> :call MinWin()<CR>" ---Minimizeendifmap<special> <silent> <C-S> :call Save()<CR>" ---Savemap<special> <silent> <C-Tab> :call SwitchWin()<CR>" ---SwitchWinimap<special> <silent> <C-S> <ESC>:write<CR>aimap<special> <silent> <C-Tab> <ESC><C-W><C-W>afunction! EditRc()if "" == expand("%:p"):edit ~/.vimrcelseif ".vimrc" != expand("%:t"):split ~/.vimrcendifendfunctionfunction! Test()let s:buf_name = "suren"if !bufexists(s:buf_name) || bufwinnr(s:buf_name) == -125vsplit surenset modifiableset buftype=nofileredir @asilent mapredir ENDsilent execute "normal " . '"ap'silent :%substitute/^\n// silent :global!/\s*:call.*---/delete silent :%substitute/\s*:call.*---/\t/silent :%substitute/^\s*//silent :nohlsearchsortset nowrapset colorcolumn=""set readonlyset nomodifiableendifendfunctionfunction! SubString(str, begin, len)let str=a:strlet begin=a:beginlet len=a:lenlet length=begin+lenlet rv=""while begin < lengthlet rv=rv.str[begin]let begin=begin+1endwhilereturn rvendfunctionfunction! IndexOf(str, sub)let str=a:strlet sub=a:sublet subLen=strlen(sub)let len=strlen(str)let len=len-subLen+1let i=0while i < lenif SubString(str, i, subLen) == subreturn iendiflet i=i+1endwhilereturn -1endfunctionfunction! LastIndexOf(str, sub)let str=a:strlet sub=a:sublet len=strlen(str)let subLen=strlen(sub)let i=len-subLenwhile i >= 0if SubString(str, i,subLen) == subreturn iendiflet i=i-1endwhilereturn -1endfunctionfunction! SortFunc(x, y)let s:index = 0let 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 = 0let s:y_is_num = 0if s:x_list == s:y_listreturn 0elseif s:x_len == 0return -1elseif s:y_len == 0return 1endiffor i in s:x_listlet s:x = ilet s:y = s:y_list[s:index]let s:x_is_num = s:x + 0let s:y_is_num = s:y + 0if s:x_is_num != 0let s:x = s:x_is_numendifif s:y_is_num != 0let s:y = s:y_is_numendifif s:x > s:yreturn 1endifif s:x < s:yreturn -1endiflet s:index = s:index + 1if s:index >= s:y_lenbreakendifendforreturn 0endfunctionfunction! Sort(from, to)let s:begin = a:from + 0let s:end = a:to + 0if s:begin <= 0let s:begin = 1endifif s:end <= 0let s:end = 1endifif s:begin > line("$") || s:end > line("$")returnendiflet 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)$deleteendfunctionfunction! DeleteLine(from, to)let s:begin = a:from + 0let s:end = a:to + 0if s:begin < 0 || s:begin > line("$")returnendifif s:end < 0 || s:end > line("$")returnendifexecute "normal " . s:begin . "gg"execute ":" . s:begin . "," . s:end . "delete"endfunctionfunction! Quit()silent :quitendfunctionfunction! ContentReload()silent :eexecute "normal G"endfunctionfunction! OpenShell()if has("gui_win32")silent execute "!start cmd"endifendfunctionfunction! OpenTaskMgr()if has("gui_win32")silent execute "!start taskmgr"endifendfunctionif !exists("*ReloadRc")function! ReloadRc()silent :source ~/.vimrcendfunctionendifif !exists("*ReloadFile")function! ReloadFile()silent :eexecute "normal " . s:begin . "G"endfunctionendiffunction! SwapMouse()let s:suren_lib = findfile("suren.dll", &runtimepath)if s:suren_lib != ""call libcall(s:suren_lib, "SwapMouse", "")endifendfunctionfunction! 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 = 0endifif s:suren_lib != ""let s:suren_lib = s:suren_lib_strif s:suren_fullscreen == 0echo s:suren_liblet s:suren_win_info =  libcall(s:suren_lib, "FullScreen", "")if len(split(s:suren_win_info)) == 4let s:suren_win_last_left = split(s:suren_win_info)[0] + 0let s:suren_win_last_top = split(s:suren_win_info)[1] + 0let s:suren_win_last_right = split(s:suren_win_info)[2] + 0let s:suren_win_last_bottom = split(s:suren_win_info)[3] + 0set guioptions-=mset guioptions-=Tlet s:suren_fullscreen = 1endifelsecall 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+=mset guioptions+=Tlet s:suren_fullscreen = 0endifelseecho "can't found " . s:suren_lib_strendifendfunctionfunction! MaxWin()simalt ~xendfunctionfunction! MinWin()simalt ~nendfunctionfunction! RestoreWin()simalt ~rendfunctionfunction! SwitchWin()execute "normal \<C-W>\<C-W>"endfunctionfunction! Save()let s:path = expand("%:p")if s:path == ""if has("gui")execute ":browse confirm saveas"elselet s:path = input("saveas:")execute ":write " . s:pathendifelseexecute ":write"endifendfunction

    [/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/

0 0