`
javasee
  • 浏览: 920407 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

史上最强的适合gvim7.2 和gvim7.3(Windows)的配置文件(2011-03-10更新)--amix.dk--小方更改

 
阅读更多

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" 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

"

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Added by Paul Lan lanshunfang#gmail.com

" => 圣经·新约·约翰福音 3:16 神爱世人,甚至将祂的独生子耶稣基督赐给他们,叫一切信祂的不至灭亡,反得永生

" => 本Vim经过Paul修改,所以只适用于Windows下的GVIM

" => 如果你硬要应用于Linux下,请搜索 Mysys()函数定义,修改返回值。

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" see this: http://vim.wikia.com/wiki/Switch_between_Vim_window_splits_easily

" Now I can hold down Ctrl and move between windows with the standard Vim movement keys. Much, much quicker!

map <C-J> <C-W>j<C-W>_

map <C-K> <C-W>k<C-W>_

au BufRead,BufNewFile *.js set ft=javascript syntax=jquery " jQuery syntax: http://www.vim.org/scripts/script.php?script_id=2416

" add set ai for phtml

au BufRead,BufNewFile *.phtml set nu " add ai and nu support for phtml

au BufRead,BufNewFile *.phtml set ai " add ai and nu support for phtml

" highlight length over 120 charatcters : http://stackoverflow.com/questions/235439/vim-80-column-layout-concerns

au BufRead,BufNewFile *.js highlight OverLength ctermbg=red ctermfg=white guibg=#592929 " add ai and nu support for phtml

au BufRead,BufNewFile *.js match DiffAdd '/%>120v.*'

let Tlist_Ctags_Cmd = "D://dev//VIM//ctags58//ctags.exe" " for taglist, you need donwnload the ctags.exe from sourceforge

let g:ctags_path="D://dev//VIM//ctags58" " for ctag.vim

let g:ctags_statusline=1 " for ctag.vim

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => General

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Sets how many lines of history VIM has to remember

func! MySys()

return 'windows'

endfunc

set history=700

" Enable filetype plugin

filetype plugin on

filetype indent on

" Set to auto read when a file is changed from the outside

set autoread

" With a map leader it's possible to do extra key combinations

" like <leader>w saves the current file

let mapleader = ","

let g:mapleader = ","

" Fast saving

nmap <leader>w :w!<cr>

" Fast editing of the .vimrc

map <leader>e :e! ~/.vim_runtime/vimrc<cr>

" When vimrc is edited, reload it

autocmd! bufwritepost vimrc source ~/.vim_runtime/vimrc

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => VIM user interface

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Set 7 lines to the curors - when moving vertical..

set so=7

set wildmenu "Turn on WiLd menu

set ruler "Always show current position

set cmdheight=2 "The commandbar height

set hid "Change buffer - without saving

" Set backspace config

set backspace=eol,start,indent

set whichwrap+=<,>,h,l

set ignorecase "Ignore case when searching

set smartcase

set hlsearch "Highlight search things

set incsearch "Make search act like search in modern browsers

set nolazyredraw "Don't redraw while executing macros

set magic "Set magic on, for regular expressions

set showmatch "Show matching bracets when text indicator is over them

set mat=2 "How many tenths of a second to blink

" No sound on errors

set noerrorbells

set novisualbell

set t_vb=

set tm=500

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Colors and Fonts

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

syntax enable "Enable syntax hl

" Set font according to system

if MySys() == "mac"

set gfn=Menlo:h14

set shell=/bin/bash

elseif MySys() == "windows"

set gfn=Bitstream/ Vera/ Sans/ Mono:h10

elseif MySys() == "linux"

set gfn=Monospace/ 10

set shell=/bin/bash

endif

if has("gui_running")

set guioptions-=T

set t_Co=256

set background=dark

colorscheme darkblue

set nonu

else

colorscheme zellner

set background=dark

set nonu

endif

try

lang en_US

catch

endtry

set ffs=unix,dos,mac "Default file types

" 配置多语言环境,解决中文乱码问题

if has("multi_byte")

" UTF-8 编码

set encoding=utf-8

set termencoding=utf-8

set formatoptions+=mM

set fencs=utf-8,gbk

if v:lang =~? '^/(zh/)/|/(ja/)/|/(ko/)'

set ambiwidth=double

endif

if has("win32")

source $VIMRUNTIME/delmenu.vim

source $VIMRUNTIME/menu.vim

language messages zh_CN.utf-8

endif

else

echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte"

endif

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Files, backups and undo

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Turn backup off, since most stuff is in SVN, git anyway...

set nobackup

set nowb

set noswapfile

"Persistent undo

try

if MySys() == "windows"

set undodir=C:/Windows/Temp

else

set undodir=~/.vim_runtime/undodir

endif

set undofile

catch

endtry

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Text, tab and indent related

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

set expandtab

set shiftwidth=4

set tabstop=4

set smarttab

set lbr

set tw=500

set ai "Auto indent

set si "Smart indet

set wrap "Wrap lines

""""""""""""""""""""""""""""""

" => Visual mode related

""""""""""""""""""""""""""""""

" Really useful!

" In visual mode when you press * or # to search for the current selection

vnoremap <silent> * :call VisualSearch('f')<CR>

vnoremap <silent> # :call VisualSearch('b')<CR>

" When you press gv you vimgrep after the selected text

vnoremap <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 Foo

endfunction

" From an idea by Michael Naumann

function! VisualSearch(direction) range

let l:saved_reg = @"

execute "normal! vgvy"

let l:pattern = escape(@", '///.*$^~[]')

let l:pattern = substitute(l:pattern, "/n$", "", "")

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_reg

endfunction

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Command mode related

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Smart mappings on the command line

cno $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 line

cno $q <C-/>eDeleteTillSlash()<cr>

" Bash like keys for the command line

cnoremap <C-A> <Home>

cnoremap <C-E> <End>

cnoremap <C-K> <C-U>

cnoremap <C-P> <Up>

cnoremap <C-N> <Down>

" Useful on some European keyboards

func! Cwd()

let cwd = getcwd()

return "e " . cwd

endfunc

func! 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_edited

endfunc

func! 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. windows

map <C-j> <C-W>j

map <C-k> <C-W>k

map <C-h> <C-W>h

map <C-l> <C-W>l

" Close the current buffer

map <leader>bd :Bclose<cr>

" Close all the buffers

map <leader>ba :1,300 bd!<cr>

" Use the arrows to something usefull

map <right> :bn<cr>

map <left> :bp<cr>

" Tab configuration

map <leader>tn :tabnew<cr>

map <leader>te :tabedit

map <leader>tc :tabclose<cr>

map <leader>tm :tabmove

" When pressing <leader>cd switch to the directory of the open buffer

map <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)

endif

endfunction

" Specify the behavior when switching between buffers

try

set switchbuf=usetab

set stal=2

catch

endtry

""""""""""""""""""""""""""""""

" => Statusline

""""""""""""""""""""""""""""""

" Always hide the statusline

set laststatus=2

" Format the statusline

set statusline=/ %{HasPaste()}%F%m%r%h/ %w/ / CWD:/ %r%{CurDir()}%h/ / / Line:/ %l/%L:%c

function! CurDir()

let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")

return curdir

endfunction

function! HasPaste()

if &paste

return 'PASTE MODE '

else

return ''

endif

endfunction

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => 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>i

inoremap $2 []<esc>i

inoremap $3 {}<esc>i

inoremap $4 {<esc>o}<esc>O

inoremap $q ''<esc>i

inoremap $e ""<esc>i

inoremap $t <><esc>i

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => General Abbrevs

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Editing mappings

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"Remap VIM 0

map 0 ^

"Move a line of text using ALT+[jk] or Comamnd+[jk] on mac

nmap <M-j> mz:m+<cr>`z

nmap <M-k> mz:m-2<cr>`z

vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z

vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z

if 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"

endfunc

autocmd BufWrite *.py :call DeleteTrailingWS()

set guitablabel=%t

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => 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=0

let g:bufExplorerShowRelativePath=1

map <leader>o :BufExplorer<cr>

""""""""""""""""""""""""""""""

" => Minibuffer plugin

""""""""""""""""""""""""""""""

let g:miniBufExplModSelTarget = 1

let g:miniBufExplorerMoreThanOne = 2

let g:miniBufExplUseSingleClick = 1

let g:miniBufExplMapWindowNavVim = 1

let g:miniBufExplVSplit = 25

let g:miniBufExplSplitBelow=1

" by paul lan

let g:miniBufExplMapWindowNavArrows = 1

let g:miniBufExplMapCTabSwitchBufs = 1

let g:bufExplorerSortBy = "name"

autocmd BufRead,BufNew :call UMiniBufExplorer

map <leader>u :TMiniBufExplorer<cr>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Omni complete functions

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

autocmd FileType css set omnifunc=csscomplete#CompleteCSS

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Spell checking

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"Pressing ,ss will toggle and untoggle spell checking

map <leader>ss :setlocal spell!<cr>

"Shortcuts using <leader>

map <leader>sn ]s

map <leader>sp [s

map <leader>sa zg

map <leader>s? z=

""""""""""""""""""""""""""""""

" => Python section

""""""""""""""""""""""""""""""

let python_highlight_all = 1

au FileType python syn keyword pythonDecorator True None False self

au BufNewFile,BufRead *.jinja set syntax=htmljinja

au BufNewFile,BufRead *.mako set ft=mako

au FileType python inoremap <buffer> $r return

au FileType python inoremap <buffer> $i import

au FileType python inoremap <buffer> $p print

au FileType python inoremap <buffer> $f #--- PH ----------------------------------------------<esc>FP2xi

au FileType python map <buffer> <leader>1 /class

au FileType python map <buffer> <leader>2 /def

au FileType python map <buffer> <leader>C ?class

au FileType python map <buffer> <leader>D ?def

""""""""""""""""""""""""""""""

" => JavaScript section

"""""""""""""""""""""""""""""""

au FileType javascript call JavaScriptFold()

au FileType javascript setl fen

au FileType javascript setl nocindent

au FileType javascript imap <c-t> AJS.log();<esc>hi

au FileType javascript imap <c-a> alert();<esc>hi

au FileType javascript inoremap <buffer> $r return

au FileType javascript inoremap <buffer> $f //--- PH ----------------------------------------------<esc>FP2xi

function! 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 = 400

map <leader>f :MRU<CR>

""""""""""""""""""""""""""""""

" => Command-T

""""""""""""""""""""""""""""""

let g:CommandTMaxHeight = 15

set wildignore+=*.o,*.obj,.git,*.pyc

noremap <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 up

noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm

"Quickly open a buffer for scripbble

map <leader>q :e ~/buffer<cr>

au BufRead,BufNewFile ~/buffer iab <buffer> xh1 ===========================================

map <leader>pp :setlocal paste!<cr>

map <leader>bb :cd ..<cr>

分享到:
评论

相关推荐

    gvim 7.2 GVIM 7.2

    GVIM 7.2 GVIM 7.2 GVIM 7.2 GVIM 7.2 GVIM 7.2

    我的gvim配置,gvim7.2

    我的gvim配置,jj or JJ is esc,color scheme is evening,and so on

    gVim 7.2 Windows下的Vim编辑器

    Vim是Linux上的著名的文本编辑器,他是早年的Vi编辑器的加强版。这个gVim是windows版的,并且有了标准的windows风格的图形界面,所以叫g(graphical)Vim。这是一个国际版本,会根据安装的平台自动选择相应语言包,...

    可以使用任何字体的 gvim-7.2.49-p1 for windows

    如果你已经安装了gvim for win32,则将压缩包里的gvim.exe(支持OLE)和vim.exe(不含图形界面)复制到 gvim 的安装目录,覆盖相应的文件即可。 如果没有安装gvim for win32 ,请去www.vim.org下载gvim for win32,...

    gVim7.2 for VC6插件

    gVim7.2 for VC6插件 VC6 替代的编辑器:gVim 尽管VC6自己带的编辑器已经可以满足日常的需要了。但是有些操作还是作起来不顺手啊。可以安装个 gVim。平时使用时用自带的,需要完成特殊任务时切换到gVim。 ...

    GVIM 7.2.293

    自己编译的GVIM,带OLE,补丁更新到7.2.293 压缩包只有GVIM.exe和gvimext.dll,覆盖到原目录。 原版请到官方下载。 编译环境:Msys, 参数: make -f Make_mvc.mak GUI=yes OLE=no USERNAME=Fanicy USERDOMAIN=...

    可以使用任何字体的 gvim-7.2.69-p1 for windows 完整压缩包

    工具栏打开文件和保存文件按钮失效。这是一个在每次编译时很容易被带进的BUG。原因在于当把windows的版本设为0x0500时,vc会默认兼容 NT 4.0,这是这个BUG的根本来源; 编译选项设置不当,导致的ole版本gvim输入法...

    gvim7.2 插件及配置

    NULL 博文链接:https://yizhilong28.iteye.com/blog/790184

    Gvim7.2中文版

    一个很好很强大的编程软件,linux下是Vim window 下是Gvim

    gvim-7.2-p2-for-windows

    请下载7.2p2或7.2.2p1,7.2p1有BUG。 有任何问题,请致电 rubble@126.com 从版本 7.1.293 开始,改用 vc express 2008 编译 需要使用微软雅黑和consolas字体搭配的,请到网上寻找微软雅黑和consolas字体的混合字体 ...

    windows下(尤其是Win7下)的gvim7.2编辑器的快速安装与配置压缩包

    其中有手把手的教你如何在Win7下快速的安装与配置强大的gvim编辑器的教程,同时有本gvim编辑器中集中有非常多的实用的vim插件,针对多种编程语言如C、C++、asm、java、php等等,支持多颜色标记,自动缩进,代码折叠...

    gvim-7.3-22.1.3.x86_64.rpm

    gvim-7.3-22.1.3.x86_64.rpm

    gvim-7.2-p1-for-windows

    &lt;br&gt;压缩包里是 gvim 的 ole 版本和不带 ole 的版本,都是基于官方的 7.2 制作。 &lt;br&gt;注意事项: 1:首先安装 YaHei Consolas Hybrid 字体; 2:如果你在 gvim 的命令行上设置字体,enc设置必须是cp936...

    GVim 7.2.441

    VIM - Vi IMproved 7.2 (2008 Aug 9, compiled May 31 2010 15:48:17) MS-Windows 32-bit GUI version Included patches: 1-441 Compiled by Administrator@LIPCORE Huge version with GUI. Features included (+) ...

    vim7.3 gvim7.3

    vim 7.3 的源代码 含有gvim vim 7.3 的源代码 含有gvim

    gVim7.2b Beta

    gVim7.2b Beta for Windows

    gvim(win32)7.3.62

    Windows 版本的 Vim,加入了多种接口。补丁为 0-62 。

Global site tag (gtag.js) - Google Analytics