givm --ZT
?
gvim 配置文件(珍藏版)
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
syntax on
set diffexpr=MyDiff()
function Del()
??? if getline(".") == getline(line(".") - 1)
??? norm dd
??? endif
endfunction
function AddHead()
??? "call setline(1,"#****************************************************")
??? call append(1,"//? +-----------------------------------------------------+")
??? call append(2,"//? |????????? Author: zenglingneng@gmail.com")
??? call append(3,"//? |??????? Filename: " . expand("%"))
??? call append(4,"//? +-----------------------------------------------------+")
??? call append(5,"//? |?? Last modified: " . strftime(": %Y-%m-%d %H:%M:%S"))
??? call append(6,"//? |???? Description: ")
??? call append(7,"//? +-----------------------------------------------------+")
??? call append(8,"")
endfunction
map T <esc>:call AddHead()<cr>
map mt <esc>:/\/\/.*Last modified: /s/:.*-.*-.*$/\=strftime(": %Y-%m-%d %H:%M:%S")/<cr><F2>
map @h <esc>:e C:\WINDOWS\system32\drivers\etc\hosts<cr>
map @p <esc>:e D:\kit\www\php\php.ini<cr>
map @m <esc>:e D:\kit\www\phpMyAdmin\config.inc.php<cr>
"vmap cc <esc>:s!^!//!g<cr>
"vmap cx <esc>:s!^\s*//!!g<cr>
map cc v:s!^!//!<cr><F2>
map cx v:s!^\s*//!!<cr><F2>
vmap cc :s!^!//!<cr><F2>
vmap cx :s!^\s*//!!<cr><F2>
vmap cx :s!^\s*//!!<cr><F2>
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
set statusline=~
color koehler
imap <C-a> <Esc>I
imap <C-e> <ESC>A
map <C-Tab> <C-W>w
imap <C-Tab> <C-O><C-W>w
cmap <C-Tab> <C-C><C-Tab>
map <F5> :bp<C-M>
map <F6> :bn<C-M>
map <F7> :bd<C-M>
set bs=2
set textwidth=120
set nobackup
"设置临时文件目录
set backupdir=D:\kit\www\tmp
set directory=D:\kit\www\tmp
"不显示高亮搜索
set nohlsearch
set noincsearch
set ignorecase
set cursorline
set so=7
set ruler
set nu
set smartcase
set mouse=a
set mousemodel=extend
set autoindent
set expandtab
set shiftwidth=4
set softtabstop=4
set tabstop=8
set smartindent
set smarttab
set cindent
set backspace=2
set wildmenu
set wildmode=list:longest,full
set nocompatible
set fileencodings=ucs-bom,utf-8,gbk
"set fileencodings=ucs-bom,utf-8,prc
" set enc=utf-8
set guioptions+=f
set noeb
set incsearch
set hls
set ttyfast
set foldmethod=marker
set tw=79
set whichwrap=b,s,<,>,[,]
set formatoptions=l
set lbr
set hid
set laststatus=2
set nowrap
set showmatch
"最大窗口
autocmd GUIEnter * simalt ~x
"设置不使用alt激活菜单
set winaltkeys=no
set guifont=Linux\ Kernel
"" Gzip and Bzip2 files support
" Take from the Debian package and the exemple on $VIM/vim_exemples
if has("autocmd")
??? " Set some sensible defaults for editing C-files
??? augroup cprog
??????? " Remove all cprog autocommands
??????? au!
??????? " When starting to edit a file:
??????? "?? For *.c and *.h files set formatting of comments and set C-indenting on.
??????? "?? For other files switch it off.
??????? "?? Don't change the order, it's important that the line with * comes first.
??????? autocmd BufRead *?????? set formatoptions=tcql nocindent comments&
??????? autocmd BufRead *.c,*.h set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
??? augroup END
??? " Also, support editing of gzip-compressed files. DO NOT REMOVE THIS!
??? " This is also used when loading the compressed helpfiles.
??? augroup gzip
??????? " Remove all gzip autocommands
??????? au!
??????? " Enable editing of gzipped files
??????? "?????? read: set binary mode before reading the file
??????? "???????????? uncompress text in buffer after reading
??????? "????? write: compress file after writing
??????? "???? append: uncompress file, append, compress file
??????? autocmd BufReadPre,FileReadPre??????? *.gz set bin
??????? autocmd BufReadPre,FileReadPre??????? *.gz let ch_save = &ch|set ch=2
??????? autocmd BufReadPost,FileReadPost????? *.gz '[,']!gunzip
??????? autocmd BufReadPost,FileReadPost????? *.gz set nobin
??????? autocmd BufReadPost,FileReadPost????? *.gz let &ch = ch_save|unlet ch_save
??????? autocmd BufReadPost,FileReadPost????? *.gz execute ":doautocmd BufReadPost " . %:r
??????? autocmd BufWritePost,FileWritePost??? *.gz !mv <afile> <afile>:r
??????? autocmd BufWritePost,FileWritePost??? *.gz !gzip <afile>:r
??????? autocmd FileAppendPre???????????????? *.gz !gunzip <afile>
??????? autocmd FileAppendPre???????????????? *.gz !mv <afile>:r <afile>
??????? autocmd FileAppendPost??????????????? *.gz !mv <afile> <afile>:r
??????? autocmd FileAppendPost??????????????? *.gz !gzip <afile>:r
??? augroup END
??? augroup bzip2
??????? " Remove all bzip2 autocommands
??????? au!
??????? " Enable editing of bzipped files
??????? "?????? read: set binary mode before reading the file
??????? "???????????? uncompress text in buffer after reading
??????? "????? write: compress file after writing
??????? "???? append: uncompress file, append, compress file
??????? autocmd BufReadPre,FileReadPre??????? *.bz2 set bin
??????? autocmd BufReadPre,FileReadPre??????? *.bz2 let ch_save = &ch|set ch=2
??????? autocmd BufReadPost,FileReadPost????? *.bz2 set cmdheight=2|'[,']!bunzip2
??????? autocmd BufReadPost,FileReadPost????? *.bz2 set cmdheight=1 nobin|execute ":doautocmd BufReadPost " . %:r
??????? autocmd BufReadPost,FileReadPost????? *.bz2 let &ch = ch_save|unlet ch_save
??????? autocmd BufWritePost,FileWritePost??? *.bz2 !mv <afile> <afile>:r
??????? autocmd BufWritePost,FileWritePost??? *.bz2 !bzip2 <afile>:r
??????? autocmd FileAppendPre???????????????? *.bz2 !bunzip2 <afile>
??????? autocmd FileAppendPre???????????????? *.bz2 !mv <afile>:r <afile>
??????? autocmd FileAppendPost??????????????? *.bz2 !mv <afile> <afile>:r
??????? autocmd FileAppendPost??????????????? *.bz2 !bzip2 -9 --repetitive-best <afile>:r
??? augroup END
endif " has ("autocmd")
"后加的行数
filetype plugin indent on
" set directory for associate files
" startup in fullscreen mode for gvim
if has('gui_running')
??? set lines=40 columns=124
endif
"
" Key bindings
"
" Key mapping to stop the search highlight
nmap <silent> <F2>????????? :nohlsearch<CR>
imap <silent> <F2> <C-O>??? :nohlsearch<CR>
" Key mapping to toggle the project window
nmap <silent> <F3> <Plug>ToggleProject<CR>
" Key mapping for the taglist.vim plugin
nmap <silent> <F9>????????? :Tlist<CR>
imap <silent> <F9> <C-O>??? :Tlist<CR>
" Key mapping to toggle line number
nmap <silent> <f12>???????? :set nu!<CR>
imap <f12> <C-O>??????????? :set nu!<CR>
" Do single charactor insert
nmap <space>??????????????? i$<esc>r
" Do reload file
nmap <silent> <F5>????????? :e!<CR>
" Do quote the current directory in command :e
cmap %%? <C-R>=expand("%:p:h") . "/" <CR>
"map <F2> msHmtgg/Last [cC]hange:\s*/e+1<CR>"_D"=strftime("%Y %b %d")<CR>p'tzt`s
"vnoremap??? *?????????????? y/\V<C-R>=substitute(escape(@@,"/\\"),"\n","\\\\n","ge")<CR><CR>
"
" Plugin setup
"
"" minibuf plugin
let g:miniBufExplMapWindowNavVim = 1 "Ctrl-<hjkl> to move to window
let g:miniBufExplTabWrap = 1 " make tabs show complete (no broken on two lines)
""let g:miniBufExplForceSyntaxEnable = 1
let g:miniBufExplModSelTarget = 1
"" Taglist Plugin
" Non-GUI setting
if !has('gui_running')
??? " do not increase the windows width in the taglist.vim plugin
??? if has('eval')
??????? let tlist_inc_winwidth=0
??? endif
??? " set text-mode menu
??? if has('wildmenu')
??????? set wildmenu
??????? set cpoptions-=<
??????? set wildcharm=<c-z>
??????? nmap <f10>????? :emenu <c-z>
??????? imap <f10> <c-o>:emenu <c-z>
??? endif
endif
"" backup plugin
let g:backup_purge = 100
au bufenter *.module set ft=php
" put these in an autocmd group, so that we can delete them easily.
augroup vimrcex
??? au!
??? " when editing a file, always jump to the last known cursor position.
??? " don't do it when the position is invalid or when inside an event handler
??? " (happens when dropping a file on gvim).
??? au bufreadpost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif
augroup end
"highlight statement cterm=bold ctermfg=none
"highlight identifier cterm=bold ctermfg=none
map <c-s-right> :bnext<return>
map <c-s-left>? :bprevious<return>
"map <c-r>?????? :call jumptosource()<return>
"map <c-s-d>???? :bdelete<return>
"format the statusline
"set statusline=\ %f%m%r%h\ %w\ \ cwd:\ %r%{curdir()}%h\ \ \ line:\ %l/%l:%c
"set statusline=%<%f\ %h%m%r%=%{\"[\".(&fenc==\"\"?&enc:&fenc).\"]\\"}%k\ %-14.(%l,%v%)\ %p
set statusline=%<%f\ %h%m%r%=%{\"[\".(&fenc==\"\"?&enc:&fenc).\"]\\"}%k\ %-14.(%l,%c%)\ %p
"使得ctrl+tab实现minibuffer中的切换
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
"光标恢复到上次推出该文件时的位置
autocmd BufReadPost * if line("‘\"") && line("'\"") <= line("$") | exe "normal '\"" | endif
"/*========================================*\
"?????????????? 常用指令收集
"\*========================================*/
"?? 系统时间
"?? :map <F7> a<C-R>=strftime("%c")<CR><esc>
"?? :s/__date__/\=strftime("%c")/
"/*---------------------------------------*\
"?????????????? 基础命令
"/*---------------------------------------*\
"?? ctrl+q????????????? 可以联合复制,粘贴,替换用 行操作
"?? ctrl+w+j ctrl+w+k (:bn :bp :bd)
"?? '.????????????????? 它移动光标到上一次的修改行
"?? `.????????????????? 它移动光标到上一次的修改点
"?? .?????????????????? 重复上次命令
"?? <C-O> :???????????? 依次沿着你的跳转记录向回跳 (从最近的一次开始)
"?? <C-I> :???????????? 依次沿着你的跳转记录向前跳
"?? ju(mps) :?????????? 列出你跳转的足迹
"?? :history :????????? 列出历史命令记录
"?? :his c :??????????? 命令行命令历史
"?? :his s :??????????? 搜索命令历史
"?? q/ :??????????????? 搜索命令历史的窗口
"?? q: :??????????????? 命令行命令历史的窗口
"?? g ctrl+g??????????? 计算文件字符
"?? {,}???????????????? 前进至上一段落前进至后一段落
"?? gg,G(2G)??????????? 文件首
"?? gd dw gf ga(进制转化)
"?? gg=G 全篇自动缩进 , =G 单行缩进
"?? crl+] 函数原型处 crl+t 回 ( ctags )
"?? ctl+p 自动补全( 编辑状态 )
"?? :X 加密保存( 要输入密码 )
"?? ? /???????? (N n)
"?? f(F,t) 查找字符
"?? w(e) 移动光标到下一个单词.
"?? 5fx 表示查找光标后第 5 个 x 字符.
"?? 5w(e) 移动光标到下五个单词.
"?? b 移动光标到上一个单词.
"?? 0 移动光标到本行最开头.
"?? ^ 移动光标到本行最开头的字符处.
"?? $ 移动光标到本行结尾处.
"?? H 移动光标到屏幕的首行.
"?? M 移动光标到屏幕的中间一行.
"?? L 移动光标到屏幕的尾行.
"?? c-f (即 ctrl 键与 f 键一同按下)
"?? c-b (即 ctrl 键与 b 键一同按下) 翻页
"?? c-d (下半页) c-u(上半页) c-e (一行滚动)
"?? zz 让光标所在的行居屏幕中央
"?? zt 让光标所在的行居屏幕最上一行
"?? zb 让光标所在的行居屏幕最下一行
"?? 在 vi 中 y 表示拷贝, d 表示删除, p 表示粘贴. 其中拷贝与删除是与光标移动命令
"?? yw 表示拷贝从当前光标到光标所在单词结尾的内容.
"?? dw 表示删除从当前光标到光标所在单词结尾的内容.
"?? y0 表示拷贝从当前光标到光标所在行首的内容.
"?? d0 表示删除从当前光标到光标所在行首的内容.
"?? y$(Y) 表示拷贝从当前光标到光标所在行尾的内容.
"?? d$(D) 表示删除从当前光标到光标所在行尾的内容.
"?? yfa 表示拷贝从当前光标到光标后面的第一个a字符之间的内容.
"?? dfa 表示删除从当前光标到光标后面的第一个a字符之间的内容.
"?? s(S),a(A),x(X),D
"?? yy 表示拷贝光标所在行.
"?? dd 表示删除光标所在行.
"?? 5yy 表示拷贝光标以下 5 行.
"?? 5dd 表示删除光标以下 5 行.
"?? y2fa 表示拷贝从当前光标到光标后面的第二个a字符之间的内容.
"?? :12,24y 表示拷贝第12行到第24行之间的内容.
"?? :12,y 表示拷贝第12行到光标所在行之间的内容.
"?? :,24y 表示拷贝光标所在行到第24行之间的内容. 删除类似.
"?? TAB 就是制表符, 单独拿出来做一节是因为这个东西确实很有用.
"?? << 输入此命令则光标所在行向左移动一个 tab.
"?? >> 输入此命令则光标所在行向右移动一个 tab.
"?? 5>> 输入此命令则光标后 5 行向右移动一个 tab.
"?? :5>>(>>>) :>>(>>>)5
"?? :12,24> 此命令将12行到14行的数据都向右移动一个 tab.
"?? :12,24>> 此命令将12行到14行的数据都向右移动两个 tab.
"?? :set shiftwidth=4 设置自动缩进 4 个空格, 当然要设自动缩进先.
"?? :set sts=4 即设置 softtabstop 为 4. 输入 tab 后就跳了 4 格.
"?? :set tabstop=4 实际的 tab 即为 4 个空格, 而不是缺省的 8 个.
"?? :set expandtab 在输入 tab 后, vim 用恰当的空格来填充这个 tab.
"?? :g/^/exec 's/^/'.strpart(line('.').' ', 0, 4) 在行首插入行号
"?? set ai 设置自动缩进
"?? 5ia<esc> 重复插入5个a字符
"/*---------------------------------------*\
"?????????????? 替换命令
"/*---------------------------------------*\
"?? 替换文字 2009-02-34 ----> 2009-02-34 00:00:00
"?? :%s/\(\d\{4\}-\d\{2\}-\d\{2\}\)/\1 00:00:00/g
"?? :s/aa/bb/g????????????? 将光标所在行出现的所有包含 aa 的字符串中的 aa 替换为 bb
"?? :s/\/bb/g?????????????? 将光标所在行出现的所有 aa 替换为 bb, 仅替换 aa 这个单词
"?? :%s/aa/bb/g???????????? 将文档中出现的所有包含 aa 的字符串中的 aa 替换为 bb
"?? :12,23s/aa/bb/g???????? 将从12行到23行中出现的所有包含 aa 的字符串中的 aa 替换为 bb
"?? :12,23s/^/#/??????????? 将从12行到23行的行首加入 # 字符
"?? :%s/fred/joe/igc??????????? 一个常见的替换命令,修饰符igc和perl中一样意思
"?? s/dick/joe/igc则??????? 对于这些满足条件的行进行替换
"?? :g/^\s*$/d????????????? 空行(空格也不包含)删除.
"?? :%s/\r//g?????????????? 删除DOS方式的回车^M
"?? :%s/ *$//?????????????? 删除行尾空白(%s/\s*$//g)
"?? :g!/^dd/d?????????????? 删除不含字符串'dd'开头的行
"?? :v/^dd/d??????????????? 同上,译释:v == g!,就是不匹配!
"?? :v/./.,/./-1join??????? 压缩空行(多行空行合并为一行)
"?? :g/^$/,/./-j??????????? 压缩空行(多行空行合并为一行)
"?? :g/^/pu _?????????????? 把文中空行扩增一倍 (pu = put),原来两行间有一个空行,现在变成2个
"?? :g/^/m0???????????????? 按行翻转文章 (m = move)
"?? :g/fred/,/joe/d???????? not line based (very powerfull)
"?? :g/<input\|<form/p????? 或者 要用\|
"?? :g/fred/t$????????????? 拷贝行,从fred到文件末尾(EOF)
"?? :%norm jdd????????????? 隔行删除,译释:%指明是对所有行进行操作,norm指出后面是normal模式的指令,j是下移一行,dd是删除行
"?? :'a,'bg/fred/s/dick/joe/igc?? ('a,'b指定一个范围:mark a ~ mark b)
"?? g//用一个正则表达式指出了进行操作的行必须可以被fred匹配,g//是一个全局显示命令
"?? /joe/e????????????????? 光标停留在匹配单词最后一个字母处
"?? /joe/e+1??????????????? 光标停留在匹配单词最后一个字母的下一个字母处
"?? /joe/s????????????????? 光标停留在匹配单词第一个字母处
"?? /^joe.*fred.*bill/????? 标准正则表达式
"?? /^[A-J]\+/????????????? 找一个以A~J中一个字母重复两次或以上开头的行
"?? /forum\(\_.\)*pent????? 多行匹配
"?? /fred\_s*joe/i????????? 中间可以有任何空白,包括换行符\n
"?? /fred\|joe????????????? 匹配FRED或JOE
"?? /\<fred\>/i???????????? 匹配fred,fred必须是一个独立的单词,而不是子串
"?? /\<\d\d\d\d\>?????????? 匹配4个数字 \<\d\{4}\>
"?? 列,替换所有在第三列中的str1
"?? :%s:\(\(\w\+\s\+\)\{2}\)str1:\1str2:
"?? 交换第一列和最后一列 (共4列)
"?? :%s:\(\w\+\)\(.*\s\+\)\(\w\+\)$:\3\2\1:
"?? 全局(global)显示命令,就是用 :g+正则表达式
"?? 译释: :g/{pattern}/{cmd} 就是全局找到匹配的,然后对这些行执行命令{cmd}
"?? :g/\<fred\>/??????????????????????????????? 显示所有能够为单词fred所匹配的行
"?? :g/<pattern>/z#.5?????????????????????????? 显示内容,还有行号
"?? :g/<pattern>/z#.5|echo '=========='???????? 漂亮的显示
"/*---------------------------------------*\
"?????????? 多文操作 (基础)
"/*---------------------------------------*\
"??? 用 :ls! 可以显示出当前所有的buffer
"?? :bn???????????????? 跳转到下一个buffer
"?? :bp???????????????? 跳转到上一个buffer
"?? :wn???????????????? 存盘当前文件并跳转到下一个
"?? :wp???????????????? 存盘当前文件并跳转到上一个
"?? :bd???????????????? 把这个文件从buffer列表中做掉
"?? :b 3??????????????? 跳到第3个buffer
"?? :b main???????????? 跳到一个名字中包含main的buffer
"/*---------------------------------------*\
"?????????? 列复制
"/*---------------------------------------*\
"?? 译注:@#%&^#*^%#$!
"?? :%s= [^ ]\+$=&&= : 复制最后一列
"?? :%s= \f\+$=&&= : 一样的功能
"?? :%s= \S\+$=&& : ft,还是一样
"?? 反向引用,或称记忆
"?? :s/\(.*\):\(.*\)/\2 : \1/ : 颠倒用:分割的两个字段
"?? :%s/^\(.*\)\n\1/\1$/ : 删除重复行
"?? 非贪婪匹配,\{-}
"?? :%s/^.\{-}pdf/new.pdf/ : 只是删除第一个pdf
"?? 跨越可能的多行
"?? :%s/<!--\_.\{-}-->// : 又是删除多行注释(咦?为什么要说「又」呢?)
"?? :help /\{-} : 看看关于 非贪婪数量符 的帮助
"?? :s/fred/<c-r>a/g : 替换fred成register a中的内容,呵呵
"?? 写在一行里的复杂命令
"?? :%s/\f\+\.gif\>/\r&\r/g | v/\.gif$/d | %s/gif/jpg/
"?? 译注:就是用 | 管道啦
"/*---------------------------------------*\
"?????????? 大小写转换
"/*---------------------------------------*\
"?? g~~ : 行翻转
"?? vEU : 字大写(广义字)
"?? vE~ : 字翻转(广义字)
"?? ~?? 将光标下的字母改变大小写
"?? 3~? 将下3个字母改变其大小写
"?? g~w 字翻转
"?? U?? 将可视模式下的字母全改成大写字母
"?? gUU 将当前行的字母改成大写
"?? u?? 将可视模式下的字母全改成小写
"?? guu 将当前行的字母全改成小写
"?? gUw 将光标下的单词改成大写。
"?? guw 将光标下的单词改成小写。
"?? 文件浏览
"?? :Ex : 开启目录浏览器,注意首字母E是大写的
"?? :Sex : 在一个分割的窗口中开启目录浏览器
"?? :ls : 显示当前buffer的情况
"?? :cd .. : 进入父目录
"?? :pwd
"?? :args : 显示目前打开的文件
"?? :lcd %:p:h : 更改到当前文件所在的目录
"??? 译释:lcd是紧紧改变当前窗口的工作路径,% 是代表当前文件的文件名,
"??? 加上 :p扩展成全名(就是带了路径),加上 :h析取出路径
"/*========================================*\
"?????????????????? END
"\*========================================*/
?
?