MACVIM的配置文件.gvimrc备份

来源:互联网 发布:java去掉html标签样式 编辑:程序博客网 时间:2024/05/17 08:13

该配置是楼主从网上找的,源地址忘记了,所以未注明转载地址,但是作者的title等说明信息一概保留,楼主修改了部分信息,包括字体,文件编码,colorscheme等,仅作备份


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Maintainer: amix the lucky stiff"             http://amix.dk - amix@amix.dk"" Version: 3.6 - 25/08/10 14:40:30"" Blog_post: "       http://amix.dk/blog/post/19486#The-ultimate-vim-configuration-vimrc" Syntax_highlighted:"       http://amix.dk/vim/vimrc.html" Raw_version: "       http://amix.dk/vim/vimrc.txt"" How_to_Install_on_Unix:"    $ mkdir ~/.vim_runtime"    $ svn co svn://orangoo.com/vim ~/.vim_runtime"    $ cat ~/.vim_runtime/install.sh"    $ sh ~/.vim_runtime/install.sh <system>"      <sytem> can be `mac`, `linux` or `windows`"" How_to_Upgrade:"    $ svn update ~/.vim_runtime"" Sections:"    -> General"    -> VIM user interface"    -> Colors and Fonts"    -> Files and backups"    -> Text, tab and indent related"    -> Visual mode related"    -> Command mode related"    -> Moving around, tabs and buffers"    -> Statusline"    -> Parenthesis/bracket expanding"    -> General Abbrevs"    -> Editing mappings""    -> Cope"    -> Minibuffer plugin"    -> Omni complete functions"    -> Python section"    -> JavaScript section""" Plugins_Included:"     > minibufexpl.vim - http://www.vim.org/scripts/script.php?script_id=159"       Makes it easy to get an overview of buffers:"           info -> :e ~/.vim_runtime/plugin/minibufexpl.vim""     > bufexplorer - http://www.vim.org/scripts/script.php?script_id=42"       Makes it easy to switch between buffers:"           info -> :help bufExplorer""     > yankring.vim - http://www.vim.org/scripts/script.php?script_id=1234"       Emacs's killring, useful when using the clipboard:"           info -> :help yankring""     > surround.vim - http://www.vim.org/scripts/script.php?script_id=1697"       Makes it easy to work with surrounding text:"           info -> :help surround""     > snipMate.vim - http://www.vim.org/scripts/script.php?script_id=2540"       Snippets for many languages (similar to TextMate's):"           info -> :help snipMate""     > mru.vim - http://www.vim.org/scripts/script.php?script_id=521"       Plugin to manage Most Recently Used (MRU) files:"           info -> :e ~/.vim_runtime/plugin/mru.vim""     > Command-T - http://www.vim.org/scripts/script.php?script_id=3025"       Command-T plug-in provides an extremely fast, intuitive mechanism for opening filesa:"           info -> :help CommandT"           screencast and web-help -> http://amix.dk/blog/post/19501"""  Revisions:"     > 3.6: Added lots of stuff (colors, Command-T, Vim 7.3 persistent undo etc.)"     > 3.5: Paste mode is now shown in status line  if you are in paste mode"     > 3.4: Added mru.vim"     > 3.3: Added syntax highlighting for Mako mako.vim "     > 3.2: Turned on python_highlight_all for better syntax"            highlighting for Python"     > 3.1: Added revisions ;) and bufexplorer.vim"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => General"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Sets how many lines of history VIM has to rememberset history=700" Enable filetype pluginfiletype plugin onfiletype indent on" Set to auto read when a file is changed from the outsideset autoread" With a map leader it's possible to do extra key combinations" like <leader>w saves the current filelet mapleader = ","let g:mapleader = ","" Fast savingnmap <leader>w :w!<cr>" Fast editing of the .vimrcmap <leader>e :e! ~/.vim_runtime/vimrc<cr>" When vimrc is edited, reload itautocmd! bufwritepost vimrc source ~/.vim_runtime/vimrc"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => VIM user interface"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Set 7 lines to the curors - when moving vertical..set so=7set wildmenu "Turn on WiLd menuset ruler "Always show current positionset cmdheight=2 "The commandbar heightset hid "Change buffer - without saving" Set backspace configset backspace=eol,start,indentset whichwrap+=<,>,h,lset ignorecase "搜索时忽略大小写set smartcaseset hlsearch "开启搜索高亮set incsearch "输入搜索字符串的同时进行搜索set nolazyredraw "Don't redraw while executing macros set magic "Set magic on, for regular expressionsset showmatch "Show matching bracets when text indicator is over themset mat=2 "How many tenths of a second to blink" No sound on errorsset noerrorbellsset novisualbellset t_vb=set tm=500"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Colors and Fonts"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""syntax enable "开启代码高亮func! MySys()  return "mac"endfunc" Set font according to systemif MySys() == "mac"  set gfn=SimSun:h16  set shell=/bin/bashelseif MySys() == "windows"  set gfn=Bitstream\ Vera\ Sans\ Mono:h10elseif MySys() == "linux"  set gfn=Monospace\ 10  set shell=/bin/bashendifif has("gui_running")  set guioptions-=T  set t_Co=256  colorscheme laphpendifset numberset encoding=utf-8set fileencodings=utf-8,chinese,latin-1source $VIMRUNTIME/delmenu.vimsource $VIMRUNTIME/menu.vimtry    lang en_UScatchendtryset ffs=unix,dos,mac "Default file types"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Files, backups and undo"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Turn backup off, since most stuff is in SVN, git anyway...set nobackupset nowbset noswapfile"Persistent undotry    if MySys() == "windows"      set undodir=C:\Windows\Temp    else      set undodir=~/.vim_runtime/undodir    endif    set undofilecatchendtry"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Text, tab and indent related"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""set expandtabset shiftwidth=4set tabstop=4set smarttabset lbrset tw=500set ai "Auto indentset si "Smart indetset wrap "Wrap lines""""""""""""""""""""""""""""""" => Visual mode related""""""""""""""""""""""""""""""" Really useful!"  In visual mode when you press * or # to search for the current selectionvnoremap <silent> * :call VisualSearch('f')<CR>vnoremap <silent> # :call VisualSearch('b')<CR>" When you press gv you vimgrep after the selected textvnoremap <silent> gv :call VisualSearch('gv')<CR>map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>function! CmdLine(str)    exe "menu Foo.Bar :" . a:str    emenu Foo.Bar    unmenu Fooendfunction" From an idea by Michael Naumannfunction! VisualSearch(direction) range    let l:saved_reg = @"    execute "normal! vgvy"    let l:pattern = escape(@", '\\/.*$^~[]')    let l:pattern = substitute(l:pattern, "\n{1}quot;, "", "")    if a:direction == 'b'        execute "normal ?" . l:pattern . "^M"    elseif a:direction == 'gv'        call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')    elseif a:direction == 'f'        execute "normal /" . l:pattern . "^M"    endif    let @/ = l:pattern    let @" = l:saved_regendfunction"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Command mode related"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Smart mappings on the command linecno $h e ~/cno $d e ~/Desktop/cno $j e ./cno $c e <C-\>eCurrentFileDir("e")<cr>" $q is super useful when browsing on the command linecno $q <C-\>eDeleteTillSlash()<cr>" Bash like keys for the command linecnoremap <C-A>      <Home>cnoremap <C-E>      <End>cnoremap <C-K>      <C-U>cnoremap <C-P> <Up>cnoremap <C-N> <Down>" Useful on some European keyboardsmap ½ $imap ½ $vmap ½ $cmap ½ $func! Cwd()  let cwd = getcwd()  return "e " . cwd endfuncfunc! DeleteTillSlash()  let g:cmd = getcmdline()  if MySys() == "linux" || MySys() == "mac"    let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "")  else    let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\]\\).*", "\\1", "")  endif  if g:cmd == g:cmd_edited    if MySys() == "linux" || MySys() == "mac"      let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "")    else      let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\\]\\).*\[\\\\\]", "\\1", "")    endif  endif  return g:cmd_editedendfuncfunc! CurrentFileDir(cmd)  return a:cmd . " " . expand("%:p:h") . "/"endfunc"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Moving around, tabs and buffers"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Map space to / (search) and c-space to ? (backgwards search)map <space> /map <c-space> ?map <silent> <leader><cr> :noh<cr>" Smart way to move btw. windowsmap <C-j> <C-W>jmap <C-k> <C-W>kmap <C-h> <C-W>hmap <C-l> <C-W>l" Close the current buffermap <leader>bd :Bclose<cr>" Close all the buffersmap <leader>ba :1,300 bd!<cr>" Use the arrows to something usefullmap <right> :bn<cr>map <left> :bp<cr>" Tab configurationmap <leader>tn :tabnew<cr>map <leader>te :tabeditmap <leader>tc :tabclose<cr>map <leader>tm :tabmove" When pressing <leader>cd switch to the directory of the open buffermap <leader>cd :cd %:p:h<cr>command! Bclose call <SID>BufcloseCloseIt()function! <SID>BufcloseCloseIt()   let l:currentBufNum = bufnr("%")   let l:alternateBufNum = bufnr("#")   if buflisted(l:alternateBufNum)     buffer #   else     bnext   endif   if bufnr("%") == l:currentBufNum     new   endif   if buflisted(l:currentBufNum)     execute("bdelete! ".l:currentBufNum)   endifendfunction" Specify the behavior when switching between buffers try  set switchbuf=usetab  set stal=2catchendtry""""""""""""""""""""""""""""""" => Statusline""""""""""""""""""""""""""""""" Always hide the statuslineset laststatus=2" Format the statuslineset statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%cfunction! CurDir()    let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")    return curdirendfunctionfunction! HasPaste()    if &paste        return 'PASTE MODE  '    else        return ''    endifendfunction"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Parenthesis/bracket expanding""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""vnoremap $1 <esc>`>a)<esc>`<i(<esc>vnoremap $2 <esc>`>a]<esc>`<i[<esc>vnoremap $3 <esc>`>a}<esc>`<i{<esc>vnoremap $ <esc>`>a"<esc>`<i"<esc>vnoremap $q <esc>`>a'<esc>`<i'<esc>vnoremap $e <esc>`>a"<esc>`<i"<esc>" Map auto complete of (, ", ', [inoremap $1 ()<esc>iinoremap $2 []<esc>iinoremap $3 {}<esc>iinoremap $4 {<esc>o}<esc>Oinoremap $q ''<esc>iinoremap $e ""<esc>iinoremap $t <><esc>i"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => General Abbrevs"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Editing mappings""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Remap VIM 0map 0 ^"Move a line of text using ALT+[jk] or Comamnd+[jk] on macnmap <M-j> mz:m+<cr>`znmap <M-k> mz:m-2<cr>`zvmap <M-j> :m'>+<cr>`<my`>mzgv`yo`zvmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`zif MySys() == "mac"  nmap <D-j> <M-j>  nmap <D-k> <M-k>  vmap <D-j> <M-j>  vmap <D-k> <M-k>endif"Delete trailing white space, useful for Python ;)func! DeleteTrailingWS()  exe "normal mz"  %s/\s\+$//ge  exe "normal `z"endfuncautocmd BufWrite *.py :call DeleteTrailingWS()set guitablabel=%t"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => short Tab Label"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""set guitablabel=%{ShortTabLabel()}function ShortTabLabel ()  let bufnrlist = tabpagebuflist (v:lnum)  let label = bufname (bufnrlist[tabpagewinnr (v:lnum) -1])  let filename = fnamemodify (label, ':t')  return filenameendfunction"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Cope"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Do :help cope if you are unsure what cope is. It's super useful!map <leader>cc :botright cope<cr>map <leader>n :cn<cr>map <leader>p :cp<cr>""""""""""""""""""""""""""""""" => bufExplorer plugin""""""""""""""""""""""""""""""let g:bufExplorerDefaultHelp=0let g:bufExplorerShowRelativePath=1map <leader>o :BufExplorer<cr>""""""""""""""""""""""""""""""" => Minibuffer plugin""""""""""""""""""""""""""""""let g:miniBufExplModSelTarget = 1let g:miniBufExplorerMoreThanOne = 2let g:miniBufExplModSelTarget = 0let g:miniBufExplUseSingleClick = 1let g:miniBufExplMapWindowNavVim = 1let g:miniBufExplVSplit = 25let g:miniBufExplSplitBelow=1let g:bufExplorerSortBy = "name"autocmd BufRead,BufNew :call UMiniBufExplorermap <leader>u :TMiniBufExplorer<cr>"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Omni complete functions"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""autocmd FileType css set omnifunc=csscomplete#CompleteCSS"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => Spell checking""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""Pressing ,ss will toggle and untoggle spell checkingmap <leader>ss :setlocal spell!<cr>"Shortcuts using <leader>map <leader>sn ]smap <leader>sp [smap <leader>sa zgmap <leader>s? z=""""""""""""""""""""""""""""""" => Python section""""""""""""""""""""""""""""""let python_highlight_all = 1au FileType python syn keyword pythonDecorator True None False selfau BufNewFile,BufRead *.jinja set syntax=htmljinjaau BufNewFile,BufRead *.mako set ft=makoau FileType python inoremap <buffer> $r returnau FileType python inoremap <buffer> $i importau FileType python inoremap <buffer> $p printau FileType python inoremap <buffer> $f #--- PH ----------------------------------------------<esc>FP2xiau FileType python map <buffer> <leader>1 /classau FileType python map <buffer> <leader>2 /defau FileType python map <buffer> <leader>C ?classau FileType python map <buffer> <leader>D ?def""""""""""""""""""""""""""""""" => JavaScript section"""""""""""""""""""""""""""""""au FileType javascript call JavaScriptFold()au FileType javascript setl fenau FileType javascript setl nocindentau FileType javascript imap <c-t> AJS.log();<esc>hiau FileType javascript imap <c-a> alert();<esc>hiau FileType javascript inoremap <buffer> $r returnau FileType javascript inoremap <buffer> $f //--- PH ----------------------------------------------<esc>FP2xifunction! JavaScriptFold()    setl foldmethod=syntax    setl foldlevelstart=1    syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend    function! FoldText()    return substitute(getline(v:foldstart), '{.*', '{...}', '')    endfunction    setl foldtext=FoldText()endfunction""""""""""""""""""""""""""""""" => MRU plugin""""""""""""""""""""""""""""""let MRU_Max_Entries = 400map <leader>f :MRU<CR>""""""""""""""""""""""""""""""" => Command-T""""""""""""""""""""""""""""""let g:CommandTMaxHeight = 15set wildignore+=*.o,*.obj,.git,*.pycnoremap <leader>j :CommandT<cr>noremap <leader>y :CommandTFlush<cr>""""""""""""""""""""""""""""""" => Vim grep""""""""""""""""""""""""""""""let Grep_Skip_Dirs = 'RCS CVS SCCS .svn generated'set grepprg=/bin/grep\ -nH"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => MISC"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Remove the Windows ^M - when the encodings gets messed upnoremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm"Quickly open a buffer for scripbblemap <leader>q :e ~/buffer<cr>au BufRead,BufNewFile ~/buffer iab <buffer> xh1 ===========================================map <leader>pp :setlocal paste!<cr>map <leader>bb :cd ..<cr>"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" => tag list"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""let Tlist_Ctags_Cmd="/usr/local/bin/ctags"let Tlist_Use_Right_Window=1

该配置支持mac os / windows / linux ,其他系统的同学可以将func! MySys()的返回值改成自己相应的系统。

由于楼主也不全懂,所以对于配置参数的说明,后面如果有时间再加