对于UNIX/linux初学者来说,在用VI来写程序的时候,总是发现不如WINDOWS下面的那些专业的文本编辑器那样高亮关键字,自动对齐等等...其实我们只要对VI进行一些简单的配置,即可实现很多美妙的功能,通过下面的配置,你就会发现,VI的灵活性几乎超乎于你的想象...
一般来说,我们可以在当前用户的根目录下创建一个.vimrc的隐藏文件(当然,也可以不隐藏,看个人的习惯),方法如下:
$ touch ~/.vimrc
符号~(可能很多人知道这个符号什么意思,却不会读,这个符号叫鄂化符号)在这里指当前用户的根目录,在创建新用户的时候会在/etc/passwd文件中的第六个字段说明主目录(如果你创建用户的时候没有指定根目录,默认为:/home/usrname),下面我们具体来看看.vimrc的配置...
$ vi ~/.vimrc
你可以依自己的爱好选择如下内容copy到.vimrc中:
[只是为了方便写C程序,提供自动格式化,使用C风格的自动缩进,tab设置为4个space...]
set fenc=utf-8 "设定默认解码 set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936 set nocp "或者 set nocompatible 用于关闭VI的兼容模式 set number "显示行号 set ai "或者 set autoindent vim使用自动对齐,也就是把当前行的对齐格式应用到下一行 set si "或者 set smartindent 依据上面的对齐格式,智能的选择对齐方式 set tabstop=4 "设置tab键为4个空格 set sw=4 "或者 set shiftwidth 设置当行之间交错时使用4个空格 set ruler "设置在编辑过程中,于右下角显示光标位置的状态行 set incsearch "设置增量搜索,这样的查询比较smart set showmatch "高亮显示匹配的括号 set matchtime=5 "匹配括号高亮时间(单位为 1/10 s) set ignorecase "在搜索的时候忽略大小写 syntax on "高亮语法 |
[下面是网上比较流行的一些.vimrc]
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 一般设定 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 设定默认解码 set fenc=utf-8 set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936 " 不要使用vi的键盘模式,而是vim自己的 set nocompatible " history文件中需要记录的行数 set history=100 " 在处理未保存或只读文件的时候,弹出确认 set confirm " 与windows共享剪贴板 set clipboard+=unnamed " 侦测文件类型 filetype on " 载入文件类型插件 filetype plugin on " 为特定文件类型载入相关缩进文件 filetype indent on " 保存全局变量 set viminfo+=! " 带有如下符号的单词不要被换行分割 set iskeyword+=_,$,@,%,#,- " 语法高亮 syntax on " 高亮字符,让其不受100列限制 :highlight OverLength ctermbg=red ctermfg=white guibg=red guifg=white :match OverLength '/%101v.*' " 状态行颜色 highlight StatusLine guifg=SlateBlue guibg=Yellow highlight StatusLineNC guifg=Gray guibg=White """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 文件设置 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 不要备份文件(根据自己需要取舍) set nobackup " 不要生成swap文件,当buffer被丢弃的时候隐藏它 setlocal noswapfile set bufhidden=hide " 字符间插入的像素行数目 set linespace=0 " 增强模式中的命令行自动完成操作 set wildmenu " 在状态行上显示光标所在位置的行号和列号 set ruler set rulerformat=%20(%2*%<%f%=/ %m%r/ %3l/ %c/ %p%%%) " 命令行(在状态行下)的高度,默认为1,这里是2 set cmdheight=2 " 使回格键(backspace)正常处理indent, eol, start等 set backspace=2 " 允许backspace和光标键跨越行边界 set whichwrap+=<,>,h,l " 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位) set mouse=a set selection=exclusive set selectmode=mouse,key " 启动的时候不显示那个援助索马里儿童的提示 set shortmess=atI " 通过使用: commands命令,告诉我们文件的哪一行被改变过 set report=0 " 不让vim发出讨厌的滴滴声 set noerrorbells " 在被分割的窗口间显示空白,便于阅读 set fillchars=vert:/ ,stl:/ ,stlnc:/ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 搜索和匹配 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 高亮显示匹配的括号 set showmatch " 匹配括号高亮的时间(单位是十分之一秒) set matchtime=5 " 在搜索的时候忽略大小写 set ignorecase " 不要高亮被搜索的句子(phrases) set nohlsearch " 在搜索时,输入的词句的逐字符高亮(类似firefox的搜索) set incsearch " 输入:set list命令是应该显示些啥? set listchars=tab:/|/ ,trail:.,extends:>,precedes:<,eol:$ " 光标移动到buffer的顶部和底部时保持3行距离 set scrolloff=3 " 不要闪烁 set novisualbell " 我的状态行显示的内容(包括文件类型和解码) set statusline=%F%m%r%h%w/[POS=%l,%v][%p%%]/%{strftime(/"%d/%m/%y/ -/ %H:%M/")} " 总是显示状态行 set laststatus=2 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 文本格式和排版 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 自动格式化 set formatoptions=tcrqn " 继承前一行的缩进方式,特别适用于多行注释 set autoindent " 为C程序提供自动缩进 set smartindent " 使用C样式的缩进 set cindent " 制表符为4 set tabstop=4 " 统一缩进为4 set softtabstop=4 set shiftwidth=4 " 不要用空格代替制表符 set noexpandtab " 不要换行 set nowrap " 在行和段开始处使用制表符 set smarttab """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " CTags的设定 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 按照名称排序 let Tlist_Sort_Type = "name" " 在右侧显示窗口 let Tlist_Use_Right_Window = 1 " 压缩方式 let Tlist_Compart_Format = 1 " 如果只有一个buffer,kill窗口也kill掉buffer let Tlist_Exist_OnlyWindow = 1 " 不要关闭其他文件的tags let Tlist_File_Fold_Auto_Close = 0 " 不要显示折叠树 let Tlist_Enable_Fold_Column = 0 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Autocommands """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 只在下列文件类型被侦测到的时候显示行号,普通文本文件不显示 if has("autocmd") autocmd FileType xml,html,c,cs,java,perl,shell,bash,cpp,python,vim,php,ruby set number autocmd FileType xml,html vmap <C-o> <ESC>'<i<!--<ESC>o<ESC>'>o--> autocmd FileType java,c,cpp,cs vmap <C-o> <ESC>'<o/*<ESC>'>o*/ autocmd FileType html,text,php,vim,c,java,xml,bash,shell,perl,python setlocal textwidth=100 autocmd Filetype html,xml,xsl source $VIMRUNTIME/plugin/closetag.vim autocmd BufReadPost * / if line("'/"") > 0 && line("'/"") <= line("$") | / exe " normal g`/"" | / endif endif "has("autocmd") " F5编译和运行C程序,F6编译和运行C++程序 " 请注意,下述代码在windows下使用会报错 " 需要去掉./这两个字符 " C的编译和运行 map <F5> :call CompileRunGcc()<CR> func! CompileRunGcc() exec "w" exec "!gcc % -o %<" exec "! ./%<" endfunc " C++的编译和运行 map <F6> :call CompileRunGpp()<CR> func! CompileRunGpp() exec "w" exec "!g++ % -o %<" exec "! ./%<" endfunc " 能够漂亮地显示.NFO文件 set encoding=utf-8 function! SetFileEncodings(encodings) let b:myfileencodingsbak=&fileencodings let &fileencodings=a:encodings endfunction function! RestoreFileEncodings() let &fileencodings=b:myfileencodingsbak unlet b:myfileencodingsbak endfunction au BufReadPre *.nfo call SetFileEncodings('cp437')|set ambiwidth=single au BufReadPost *.nfo call RestoreFileEncodings() " 高亮显示普通txt文件(需要txt.vim脚本) au BufRead,BufNewFile * setfiletype txt " 用空格键来开关折叠 set foldenable set foldmethod=manual nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc':'zo')<CR> " minibufexpl插件的一般设置 let g:miniBufExplMapWindowNavVim = 1 let g:miniBufExplMapWindowNavArrows = 1 let g:miniBufExplMapCTabSwitchBufs = 1 let g:miniBufExplModSelTarget = 1 |
[下面这个被称为史上最强]
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " _ " __ | / " / | / " /__ | / " by Amix - http://amix.dk/ " " Maintainer: Amir Salihefendic <amix3k at gmail.com> " Version: 2.7 " Last Change: 12/10/06 00:09:21 " " Sections: " ---------------------- " General " Colors and Fonts " Fileformats " VIM userinterface " Statusline " Visual " Moving around and tabs " General Autocommands " Parenthesis/bracket expanding " General Abbrevs " Editing mappings etc. " Command-line config " Buffer realted " Files and backups " Folding " Text options " Indent " Spell checking " Plugin configuration " Yank ring " File explorer " Minibuffer " Tag list (ctags) - not used " LaTeX Suite things " Filetype generic " Todo " VIM " HTML related " Ruby & PHP section " Python section " Cheetah section " Vim section " Java section " JavaScript section " C mappings " SML " Scheme bindings " Snippets " Python " javaScript " Cope " MISC " " Tip: " If you find anything that you can't understand than do this: " help keyword OR helpgrep keywords " Example: " Go into command-line mode and type helpgrep nocompatible, ie. " :helpgrep nocompatible " then press <leader>c to see the results, or :botright cw """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " General """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Get out of VI's compatible mode.. set nocompatible "Sets how many lines of history VIM har to remember set history=400 "Enable filetype plugin filetype plugin on filetype indent on "Set to auto read when a file is changed from the outside set autoread "Have the mouse enabled all the time: set mouse=a "Set mapleader let mapleader = "," let g:mapleader = "," "Fast saving nmap <leader>w :w!<cr> nmap <leader>f :find<cr> "Fast reloading of the .vimrc map <leader>s :source ~/vim_local/vimrc<cr> "Fast editing of .vimrc map <leader>e :e! ~/vim_local/vimrc<cr> "When .vimrc is edited, reload it autocmd! bufwritepost vimrc source ~/vim_local/vimrc """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Colors and Fonts """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Enable syntax hl syntax enable "Set font to Monaco 10pt if MySys() == "mac" set gfn=Bitstream/ Vera/ Sans/ Mono:h14 set nomacatsui set termencoding=macroman elseif MySys() == "linux" set gfn=Monospace/ 11 endif if has("gui_running") set guioptions-=T let psc_style='cool' colorscheme ps_color else set background=dark colorscheme zellner endif "Some nice mapping to switch syntax (useful if one mixes different languages in one file) map <leader>1 :set syntax=cheetah<cr> map <leader>2 :set syntax=xhtml<cr> map <leader>3 :set syntax=python<cr> map <leader>4 :set ft=javascript<cr> map <leader>$ :syntax sync fromstart<cr> autocmd BufEnter * :syntax sync fromstart "Highlight current if has("gui_running") set cursorline hi cursorline guibg=#333333 hi CursorColumn guibg=#333333 endif "Omni menu colors hi Pmenu guibg=#333333 hi PmenuSel guibg=#555555 guifg=#ffffff """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Fileformats """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Favorite filetypes set ffs=unix,dos,mac nmap <leader>fd :se ff=dos<cr> nmap <leader>fu :se ff=unix<cr> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " VIM userinterface """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Set 7 lines to the curors - when moving vertical.. set so=7 "Turn on WiLd menu set wildmenu "Always show current position set ruler "The commandbar is 2 high set cmdheight=2 "Show line number set nu "Do not redraw, when running macros.. lazyredraw set lz "Change buffer - without saving set hid "Set backspace set backspace=eol,start,indent "Bbackspace and cursor keys wrap to set whichwrap+=<,>,h,l "Ignore case when searching set ignorecase set incsearch "Set magic on set magic "No sound on errors. set noerrorbells set novisualbell set t_vb= "show matching bracets set showmatch "How many tenths of a second to blink set mat=2 "Highlight search things set hlsearch """""""""""""""""""""""""""""" " Statusline """""""""""""""""""""""""""""" "Always hide the statusline set laststatus=2 function! CurDir() let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g") return curdir endfunction "Format the statusline set statusline=/ %F%m%r%h/ %w/ / CWD:/ %r%{CurDir()}%h/ / / Line:/ %l/%L:%c """""""""""""""""""""""""""""" " Visual """""""""""""""""""""""""""""" " 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" else execute "normal /" . l:pattern . "^M" endif let @/ = l:pattern let @" = l:saved_reg endfunction "Basically you press * or # to search for the current selection !! Really useful vnoremap <silent> * :call VisualSearch('f')<CR> vnoremap <silent> # :call VisualSearch('b')<CR> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Moving around and tabs """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Map space to / and c-space to ? map <space> / map <c-space> ? "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 "Actually, the tab does not switch buffers, but my arrows "Bclose function ca be found in "Buffer related" section map <leader>bd :Bclose<cr> map <down> <leader>bd "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 try set switchbuf=usetab set stal=2 catch endtry "Moving fast to front, back and 2 sides ;) imap <m-$> <esc>$a imap <m-0> <esc>0i imap <D-$> <esc>$a imap <D-0> <esc>0i """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " General Autocommands """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Switch to current dir map <leader>cd :cd %:p:h<cr> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 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 $w <esc>`>a"<esc>`<i"<esc> "Map auto complete of (, ", ', [ inoremap $1 ()<esc>:let leavechar=")"<cr>i inoremap $2 []<esc>:let leavechar="]"<cr>i inoremap $4 {<esc>o}<esc>:let leavechar="}"<cr>O inoremap $3 {}<esc>:let leavechar="}"<cr>i inoremap $q ''<esc>:let leavechar="'"<cr>i inoremap $w ""<esc>:let leavechar='"'<cr>i au BufNewFile,BufRead *./(vim/)/@! inoremap " ""<esc>:let leavechar='"'<cr>i au BufNewFile,BufRead *./(txt/)/@! inoremap ' ''<esc>:let leavechar="'"<cr>i imap <m-l> <esc>:exec "normal f" . leavechar<cr>a imap <d-l> <esc>:exec "normal f" . leavechar<cr>a """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " General Abbrevs """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "My information iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr> iab xname Amir Salihefendic """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Editing mappings etc. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Remap VIM 0 map 0 ^ "Move a line of text using control 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 func! DeleteTrailingWS() exe "normal mz" %s//s/+$//ge exe "normal `z" endfunc autocmd BufWrite *.py :call DeleteTrailingWS() set completeopt=menu """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Command-line config """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 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 "Smart mappings on the command line cno $h e ~/ cno $d e ~/Desktop/ cno $j e ./ cno $q <C-/>eDeleteTillSlash()<cr> cno $c e <C-/>eCurrentFileDir("e")<cr> cno $tc <C-/>eCurrentFileDir("tabnew")<cr> cno $th tabnew ~/ cno $td tabnew ~/Desktop/ "Bash like cnoremap <C-A> <Home> cnoremap <C-E> <End> cnoremap <C-K> <C-U> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Buffer realted """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Fast open a buffer by search for a name map <c-q> :sb "Open a dummy buffer for paste map <leader>q :e ~/buffer<cr> "Restore cursor to file position in previous editing session set viminfo='10,/"100,:20,%,n~/.viminfo au BufReadPost * if line("'/"") > 0|if line("'/"") <= line("$")|exe("norm '/"")|else|exe "norm $"|endif|endif " Buffer - reverse everything ... :) map <F9> ggVGg? " Don't close window, when deleting a buffer 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 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Files and backups """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Turn backup off set nobackup set nowb set noswapfile """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Folding """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Enable folding, I find it very useful set nofen set fdl=0 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Text options """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set expandtab set shiftwidth=2 map <leader>t2 :set shiftwidth=2<cr> map <leader>t4 :set shiftwidth=4<cr> au FileType html,python,vim,javascript setl shiftwidth=2 au FileType html,python,vim,javascript setl tabstop=2 au FileType java setl shiftwidth=4 au FileType java setl tabstop=4 set smarttab set lbr set tw=500 """""""""""""""""""""""""""""" " Indent """""""""""""""""""""""""""""" "Auto indent set ai "Smart indet set si "C-style indeting set cindent "Wrap lines set wrap """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Spell checking """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" map <leader>sn ]s map <leader>sp [s map <leader>sa zg map <leader>s? z= """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Plugin configuration """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""" " Vim Grep """""""""""""""""""""""""""""" let Grep_Skip_Dirs = 'RCS CVS SCCS .svn' let Grep_Cygwin_Find = 1 """""""""""""""""""""""""""""" " Yank Ring """""""""""""""""""""""""""""" map <leader>y :YRShow<cr> """""""""""""""""""""""""""""" " File explorer """""""""""""""""""""""""""""" "Split vertically let g:explVertical=1 "Window size let g:explWinSize=35 let g:explSplitLeft=1 let g:explSplitBelow=1 "Hide some files let g:explHideFiles='^/.,.*/.class$,.*/.swp$,.*/.pyc$,.*/.swo$,/.DS_Store$' "Hide the help thing.. let g:explDetailedHelp=0 """""""""""""""""""""""""""""" " Minibuffer """""""""""""""""""""""""""""" let g:miniBufExplModSelTarget = 1 let g:miniBufExplorerMoreThanOne = 2 let g:miniBufExplModSelTarget = 0 let g:miniBufExplUseSingleClick = 1 let g:miniBufExplMapWindowNavVim = 1 let g:miniBufExplVSplit = 25 let g:miniBufExplSplitBelow=1 let g:bufExplorerSortBy = "name" autocmd BufRead,BufNew :call UMiniBufExplorer """""""""""""""""""""""""""""" " Tag list (ctags) - not used """""""""""""""""""""""""""""" "let Tlist_Ctags_Cmd = "/sw/bin/ctags-exuberant" "let Tlist_Sort_Type = "name" "let Tlist_Show_Menu = 1 "map <leader>t :Tlist<cr> """""""""""""""""""""""""""""" " LaTeX Suite things """""""""""""""""""""""""""""" set grepprg=grep/ -nH/ $* let g:Tex_DefaultTargetFormat="pdf" let g:Tex_ViewRule_pdf='xpdf' "Bindings autocmd FileType tex map <silent><leader><space> :w!<cr> :silent! call Tex_RunLaTeX()<cr> "Auto complete some things ;) autocmd FileType tex inoremap $i /indent autocmd FileType tex inoremap $* /cdot autocmd FileType tex inoremap $i /item autocmd FileType tex inoremap $m /[<cr>/]<esc>O """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Filetype generic """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Todo """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" au BufNewFile,BufRead *.todo so ~/vim_local/syntax/amido.vim """""""""""""""""""""""""""""" " VIM """""""""""""""""""""""""""""" autocmd FileType vim map <buffer> <leader><space> :w!<cr>:source %<cr> """""""""""""""""""""""""""""" " HTML related """""""""""""""""""""""""""""" " HTML entities - used by xml edit plugin let xml_use_xhtml = 1 "let xml_no_auto_nesting = 1 "To HTML let html_use_css = 1 let html_number_lines = 0 let use_xhtml = 1 """""""""""""""""""""""""""""" " Ruby & PHP section """""""""""""""""""""""""""""" autocmd FileType ruby map <buffer> <leader><space> :w!<cr>:!ruby %<cr> autocmd FileType php compiler php autocmd FileType php map <buffer> <leader><space> <leader>cd:w<cr>:make %<cr> """""""""""""""""""""""""""""" " Python section """""""""""""""""""""""""""""" "Run the current buffer in python - ie. on leader+space au FileType python so ~/vim_local/syntax/python.vim autocmd FileType python map <buffer> <leader><space> :w!<cr>:!python %<cr> autocmd FileType python so ~/vim_local/plugin/python_fold.vim "Set some bindings up for 'compile' of python autocmd FileType python set makeprg=python/ -c/ /"import/ py_compile,sys;/ sys.stderr=sys.stdout;/ py_compile.compile(r'%')/" autocmd FileType python set efm=%C/ %.%#,%A/ / File/ /"%f/"//,/ line/ %l%.%#,%Z%[%^/ ]%//@=%m "Python iMaps au FileType python set cindent au FileType python inoremap <buffer> $r return au FileType python inoremap <buffer> $s self au FileType python inoremap <buffer> $c ##<cr>#<space><cr>#<esc>kla au FileType python inoremap <buffer> $i import au FileType python inoremap <buffer> $p print au FileType python inoremap <buffer> $d """<cr>"""<esc>O "Run in the Python interpreter function! Python_Eval_VSplit() range let src = tempname() let dst = tempname() execute ": " . a:firstline . "," . a:lastline . "w " . src execute ":!python " . src . " > " . dst execute ":pedit! " . dst endfunction au FileType python vmap <F7> :call Python_Eval_VSplit()<cr> """""""""""""""""""""""""""""" " Cheetah section """"""""""""""""""""""""""""""" autocmd FileType cheetah set ft=xml autocmd FileType cheetah set syntax=cheetah """"""""""""""""""""""""""""""" " Vim section """"""""""""""""""""""""""""""" autocmd FileType vim set nofen """"""""""""""""""""""""""""""" " Java section """"""""""""""""""""""""""""""" au FileType java inoremap <buffer> <C-t> System.out.println();<esc>hi "Java comments autocmd FileType java source ~/vim_local/macros/jcommenter.vim autocmd FileType java let b:jcommenter_class_author='Amir Salihefendic (amix@amix.dk)' autocmd FileType java let b:jcommenter_file_author='Amir Salihefendic (amix@amix.dk)' autocmd FileType java map <buffer> <F2> :call JCommentWriter()<cr> "Abbr'z autocmd FileType java inoremap <buffer> $pr private autocmd FileType java inoremap <buffer> $r return autocmd FileType java inoremap <buffer> $pu public autocmd FileType java inoremap <buffer> $i import autocmd FileType java inoremap <buffer> $b boolean autocmd FileType java inoremap <buffer> $v void autocmd FileType java inoremap <buffer> $s String "Folding function! JavaFold() setl foldmethod=syntax setl foldlevelstart=1 syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend syn match foldImports //(/n/?import./+;/n/)/+/ transparent fold function! FoldText() return substitute(getline(v:foldstart), '{.*', '{...}', '') endfunction setl foldtext=FoldText() endfunction au FileType java call JavaFold() au FileType java setl fen au BufEnter *.sablecc,*.scc set ft=sablecc """""""""""""""""""""""""""""" " JavaScript section """"""""""""""""""""""""""""""" au FileType javascript so ~/vim_local/syntax/javascript.vim 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 au FileType javascript call JavaScriptFold() au FileType javascript setl fen au FileType javascript imap <c-t> console.log();<esc>hi au FileType javascript imap <c-a> alert();<esc>hi au FileType javascript setl nocindent au FileType javascript inoremap <buffer> $r return au FileType javascript inoremap <buffer> $d //<cr>//<cr>//<esc>ka<space> au FileType javascript inoremap <buffer> $c /**<cr><space><cr>**/<esc>ka """""""""""""""""""""""""""""" " HTML """"""""""""""""""""""""""""""" au FileType html,cheetah set ft=xml au FileType html,cheetah set syntax=html """""""""""""""""""""""""""""" " C mappings """"""""""""""""""""""""""""""" autocmd FileType c map <buffer> <leader><space> :w<cr>:!gcc %<cr> """"""""""""""""""""""""""""""" " SML """"""""""""""""""""""""""""""" autocmd FileType sml map <silent> <buffer> <leader><space> <leader>cd:w<cr>:!sml %<cr> """""""""""""""""""""""""""""" " Scheme bidings """""""""""""""""""""""""""""" autocmd BufNewFile,BufRead *.scm map <buffer> <leader><space> <leader>cd:w<cr>:!petite %<cr> autocmd BufNewFile,BufRead *.scm inoremap <buffer> <C-t> (pretty-print )<esc>i autocmd BufNewFile,BufRead *.scm vnoremap <C-t> <esc>`>a)<esc>`<i(pretty-print <esc> """""""""""""""""""""""""""""" " SVN section """"""""""""""""""""""""""""""" map <F8> :new<CR>:read !svn diff<CR>:set syntax=diff buftype=nofile<CR>gg """""""""""""""""""""""""""""" " Snippets """"""""""""""""""""""""""""""" "You can use <c-j> to goto the next <++> - it is pretty smart ;) """"""""""""""""""""""""""""""" " Python """"""""""""""""""""""""""""""" autocmd FileType python inorea <buffer> cfun <c-r>=IMAP_PutTextWithMovement("def <++>(<++>):/n<++>/nreturn <++>")<cr> autocmd FileType python inorea <buffer> cclass <c-r>=IMAP_PutTextWithMovement("class <++>:/n<++>")<cr> autocmd FileType python inorea <buffer> cfor <c-r>=IMAP_PutTextWithMovement("for <++> in <++>:/n<++>")<cr> autocmd FileType python inorea <buffer> cif <c-r>=IMAP_PutTextWithMovement("if <++>:/n<++>")<cr> autocmd FileType python inorea <buffer> cifelse <c-r>=IMAP_PutTextWithMovement("if <++>:/n<++>/nelse:/n<++>")<cr> """"""""""""""""""""""""""""""" " JavaScript """"""""""""""""""""""""""""""" autocmd FileType cheetah,html,javascript inorea <buffer> cfun <c-r>=IMAP_PutTextWithMovement("function <++>(<++>) {/n<++>;/nreturn <++>;/n}")<cr> autocmd filetype cheetah,html,javascript inorea <buffer> cfor <c-r>=IMAP_PutTextWithMovement("for(<++>; <++>; <++>) {/n<++>;/n}")<cr> autocmd FileType cheetah,html,javascript inorea <buffer> cif <c-r>=IMAP_PutTextWithMovement("if(<++>) {/n<++>;/n}")<cr> autocmd FileType cheetah,html,javascript inorea <buffer> cifelse <c-r>=IMAP_PutTextWithMovement("if(<++>) {/n<++>;/n}/nelse {/n<++>;/n}")<cr> """"""""""""""""""""""""""""""" " HTML """"""""""""""""""""""""""""""" autocmd FileType cheetah,html inorea <buffer> cahref <c-r>=IMAP_PutTextWithMovement('<a href="<++>"><++></a>')<cr> autocmd FileType cheetah,html inorea <buffer> cbold <c-r>=IMAP_PutTextWithMovement('<b><++></b>')<cr> autocmd FileType cheetah,html inorea <buffer> cimg <c-r>=IMAP_PutTextWithMovement('<img src="<++>" alt="<++>" />')<cr> autocmd FileType cheetah,html inorea <buffer> cpara <c-r>=IMAP_PutTextWithMovement('<p><++></p>')<cr> autocmd FileType cheetah,html inorea <buffer> ctag <c-r>=IMAP_PutTextWithMovement('<<++>><++></<++>>')<cr> autocmd FileType cheetah,html inorea <buffer> ctag1 <c-r>=IMAP_PutTextWithMovement("<<++>><cr><++><cr></<++>>")<cr> """"""""""""""""""""""""""""""" " Java """"""""""""""""""""""""""""""" autocmd FileType java inorea <buffer> cfun <c-r>=IMAP_PutTextWithMovement("public<++> <++>(<++>) {/n<++>;/nreturn <++>;/n}")<cr> autocmd FileType java inorea <buffer> cfunpr <c-r>=IMAP_PutTextWithMovement("private<++> <++>(<++>) {/n<++>;/nreturn <++>;/n}")<cr> autocmd FileType java inorea <buffer> cfor <c-r>=IMAP_PutTextWithMovement("for(<++>; <++>; <++>) {/n<++>;/n}")<cr> autocmd FileType java inorea <buffer> cif <c-r>=IMAP_PutTextWithMovement("if(<++>) {/n<++>;/n}")<cr> autocmd FileType java inorea <buffer> cifelse <c-r>=IMAP_PutTextWithMovement("if(<++>) {/n<++>;/n}/nelse {/n<++>;/n}")<cr> autocmd FileType java inorea <buffer> cclass <c-r>=IMAP_PutTextWithMovement("class <++> <++> {/n<++>/n}")<cr> autocmd FileType java inorea <buffer> cmain <c-r>=IMAP_PutTextWithMovement("public static void main(String[] argv) {/n<++>/n}")<cr> "Presse c-q insted of space (or other key) to complete the snippet imap <C-q> <C-]> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Cope """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "For Cope map <silent> <leader><cr> :noh<cr> "Orginal for all map <leader>n :cn<cr> map <leader>p :cp<cr> map <leader>c :botright cw 10<cr> map <c-u> <c-l><c-j>:q<cr>:botright cw 10<cr> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " MISC """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Remove the Windows ^M noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm "Paste toggle - when pasting something in, don't indent. set pastetoggle=<F3> "Remove indenting on empty lines map <F2> :%s//s*$//g<cr>:noh<cr>'' "Super paste inoremap <C-v> <esc>:set paste<cr>mui<C-R>+<esc>mv'uV'v=:set nopaste<cr> "A function that inserts links & anchors on a TOhtml export. " Notice: " Syntax used is: " Link " Anchor function! SmartTOHtml() TOhtml try %s/"/s/+/*> /(./+/)</" <a href="#/1" style="color: cyan">/1<//a></g %s/"/(-/|/s/)/+/*> /(./+/)</" / / <a href="#/2" style="color: cyan;">/2<//a></g %s/"/s/+=> /(./+/)</" <a name="/1" style="color: #fff">/1<//a></g catch endtry exe ":write!" exe ":bd" endfunction |
[vim组织提供的一个配置例子]
"===================================================================================== " Description: My daily vimrc with dozens of plugins. " Originally derived from MetaCosm's http://vi-improved.o " Last Change: 0 14/05/2006 20:54:07 Leal@RAINT:_vimrc " " Author: Leal <linxiao.li AT gmail DOT com> " http://www.leal.cn " Version: 1.0065 " " Usage: 1. Prepare necessary dirs and files " $VIMDATA X:/Vim/vimdata on Win, ~/vimdata on Linux " | " |-- temp to put swap files <DIR> " |-- backup to put backup files <DIR> " |-- diary to save calendar.vim's diaries <DIR> " |-- GetLatest to save GetLatestVimScripts.vim's <DIR> " | | " | `-- GetLatestVimScripts.dat to store GLVS's items " | " |-- _vim_fav_files to store favmenu.vim's items " `-- _vim_mru_files to store mru.vim's items " " 2. Get all scripts you favor on www.vim.org better with GLVS " " 3. Get all needed utilities, especially on Windows, e.g. " wget -- WGET for Windows (win32) http://users.ugent.b " ctags -- Exuberant Ctags http://ctags.sf.net/ " " 4. If you have no idea of some option, just press K (<S-k>) on it. " " 5. HTML file is produced with :TOhtml, with colo default. " "===================================================================================== "------------------------------------------------------------------------------------- " TODO List "------------------------------------------------------------------------------------- " 1. Install Chinese Vim help helplang -> cn "------------------------------------------------------------------------------------- " general "------------------------------------------------------------------------------------- set nocompatible " use vim as vim, should be put at the very start set history=1000 " lines of Ex-mode commands, search history set browsedir=buffer " use directory of the related buffer for file browser set clipboard+=unnamed " use clipboard register '*' for all y, d, c, p ops set viminfo+=! " make sure it can save viminfo set isk+=$,%,#,- " none of these should be word dividers set confirm " raise a dialog confirm whether to save changed buffer set ffs=unix,dos,mac " favor unix ff, which behaves good under bot Winz & Linux set fenc=utf-8 " default fileencoding set fencs=utf-8,ucs-bom,euc-jp,gb18030,gbk,gb2312,cp936 map Q gq " don't use Ex-mode, use Q for formatting filetype on " enable file type detection filetype plugin on " enable loading the plugin for appropriate file type "------------------------------------------------------------------------------------- " platform dependent "------------------------------------------------------------------------------------- if has("win32") let $VIMDATA = $VIM.'/vimdata' let $VIMFILES = $VIM.'/vimfiles' let PYTHON_BIN_PATH = 'd:/foo/python/python.exe' " ensure the path right else let $VIMDATA = $HOME.'/vimdata' let $VIMFILES = $HOME.'/.vim' let PYTHON_BIN_PATH = '/usr/bin/python' set guifont=courier/ 10 endif "------------------------------------------------------------------------------------- " path/backup "------------------------------------------------------------------------------------- set backup " make backup file and leave it around set backupdir=$VIMDATA/backup " where to put backup file set directory=$VIMDATA/temp " where to put swap file set runtimepath+=$VIMDATA " add this path to rtp, support GetLatestVimScripts.vim set path=.,/usr/include/*,, " where gf, ^Wf, :find will search set tags=./tags,tags,$VIMRUNTIME/doc/tags,$VIMFILES/doc/tags " tags files CTRL-] uses set makeef=error.err " the errorfile for :make and :grep "------------------------------------------------------------------------------------- " colors "------------------------------------------------------------------------------------- set background=dark " use a dark background syntax on " syntax highlighting "------------------------------------------------------------------------------------- " gui-only settings "------------------------------------------------------------------------------------- if has("gui_running") colo inkpot " colorscheme, inkpot.vim set lines=40 " window tall and wide, only if gui_running, set columns=120 " or vim under console behaves badly endif "------------------------------------------------------------------------------------- " Vim UI "------------------------------------------------------------------------------------- set linespace=1 " space it out a little more (easier to read) set wildmenu " type :h and press <Tab> to look what happens set ruler " always show current position along the bottom set cmdheight=2 " use 2 screen lines for command-line set lazyredraw " do not redraw while executing macros (much faster) set nonumber " don't print line number set hid " allow to change buffer without saving set backspace=2 " make backspace work normal set whichwrap+=<,>,h,l " allow backspace and cursor keys to wrap set mouse=a " use mouse in all modes set shortmess=atI " shorten messages to avoid 'press a key' prompt set report=0 " tell us when anything is changed via :... set fillchars=vert:/ ,stl:/ ,stlnc:/ " make the splitters between windows be blank "------------------------------------------------------------------------------------- " visual cues "------------------------------------------------------------------------------------- set showmatch " show matching paren set matchtime=5 " 1/10 second to show the matching paren set nohlsearch " do not highlight searched for phrases set incsearch " BUT do highlight where the so far typed pattern matches set scrolloff=10 " minimal number of screen lines to keep above/below the cursor set novisualbell " use visual bell instead of beeping set noerrorbells " do not make noise set laststatus=2 " always show the status line set listchars=tab:/|/ ,trail:.,extends:>,precedes:<,eol:$ " what to show while :set list set statusline=%{VimBuddy()}/ %F%m%r%h%w/ [%{&ff}]/ [%Y]/ [/%03.3b/ /%02.2B]/ [%02v/ %03l/ %L/ %p%%] "------------------------------------------------------------------------------------- " text formatting/layout "------------------------------------------------------------------------------------- set ai " autoindent set si " smartindent set cindent " do C-style indenting set fo=tcrqn " see help (complex) set tabstop=4 " tab spacing (settings below are just to unify it) set softtabstop=4 " unify set shiftwidth=4 " unify set noexpandtab " real tabs please! set smarttab " use tabs at the start of a line, spaces elsewhere set nowrap " do not wrap lines set formatoptions+=mM " so that vim can reformat multibyte text (e.g. Chinese) "------------------------------------------------------------------------------------- " folding "------------------------------------------------------------------------------------- set foldenable " turn on folding set foldmethod=indent " make folding indent sensitive set foldlevel=100 " don't autofold anything (but I can still fold manually) set foldopen -=search " don't open folds when you search into them set foldopen -=undo " don't open folds when you undo stuff "------------------------------------------------------------------------------------- " plugin - a.vim "------------------------------------------------------------------------------------- " alternate files quickly (.c --> .h etc) "------------------------------------------------------------------------------------- " plugin - c.vim "------------------------------------------------------------------------------------- "set makeprg=g++/ % let g:C_AuthorName = 'Leal' let g:C_Email = 'linxiao.li NOSPAM gmail DOT com' "------------------------------------------------------------------------------------- " plugin - runscript.vim (for Python) "------------------------------------------------------------------------------------- "let PYTHON_BIN_PATH = ... "------------------------------------------------------------------------------------- " plugin - calendar.vim "------------------------------------------------------------------------------------- let g:calendar_diary = $VIMDATA.'/diary' " where to store your diary "------------------------------------------------------------------------------------- " plugin - mru.vim (most recently used files) "------------------------------------------------------------------------------------- let MRU_File = $VIMDATA.'/_vim_mru_files' " which file to save mru entries let MRU_Max_Entries = 20 " max mru entries in _vim_mru_files "------------------------------------------------------------------------------------- " plugin - favmenu.vim "------------------------------------------------------------------------------------- let FAV_File = $VIMDATA.'/_vim_fav_files' " which file to save favorite entries "------------------------------------------------------------------------------------- " plugin - minibufexpl.vim "------------------------------------------------------------------------------------- let g:miniBufExplTabWrap = 1 " make tabs show complete (no broken on two lines) let g:miniBufExplModSelTarget = 1 "------------------------------------------------------------------------------------- " plugin - taglist.vim "------------------------------------------------------------------------------------- if has("win32") let Tlist_Ctags_Cmd = $VIMFILES.'/ctags.exe' " location of ctags tool else let Tlist_Ctags_Cmd = '/usr/local/bin/ctags' endif let Tlist_Sort_Type = "name" " order by let Tlist_Use_Right_Window = 1 " split to the right side of the screen let Tlist_Compart_Format = 1 " show small meny let Tlist_Exist_OnlyWindow = 1 " if you are the last, kill yourself let Tlist_File_Fold_Auto_Close = 0 " do not close tags for other files let Tlist_Enable_Fold_Column = 0 " do not show folding tree "------------------------------------------------------------------------------------- " plugin - matchit.vim "------------------------------------------------------------------------------------- let b:match_ignorecase = 1 "------------------------------------------------------------------------------------- " plugin - supertab.vim "------------------------------------------------------------------------------------- " <Tab> has been mapped to SuperTab() func in that plugin "------------------------------------------------------------------------------------- " plugin - timestamp.vim "------------------------------------------------------------------------------------- let g:timestamp_regexp = '/v/C%(<Last %([cC]hanged?|[Mm]odified):/s+)@<=.*$' let g:timestamp_rep = '%w %d/%m/%Y %H:%M:%S #u@#h:#f' augroup TimeStampHtml au filetype html let b:timestamp_regexp = '/v/C%(/<!-- Timestamp:/s{-1,})@<=.{-}%(/s*--/>)@=' au filetype html let b:timestamp_rep = '%a %d/%m/%Y %r #u@#h:#f' augroup END "------------------------------------------------------------------------------------- " plugin - perl-support.vim "------------------------------------------------------------------------------------- let g:Perl_AuthorName = 'Leal' let g:Perl_Email = 'linxiao.li NOSPAM gmail DOT com' let tlist_perl_settings = 'perl;c:constants;l:labels;s:subroutines;d:POD' "------------------------------------------------------------------------------------- " utilities "------------------------------------------------------------------------------------- " select range, then hit :SuperRetab($width) - by p0g and FallingCow fu! SuperRetab(width) range sil! exe a:firstline . ',' . a:lastline . 's//v%(^ *)@<= {'. a:width .'}//t/g' endf " bind :CD to :cd %:h, then change cwd to the dir that includes current file sil! com -nargs=0 CD exe 'cd %:h' "TODO just do it fu! AddLineNo(isVM) if(a:isVM == 1) sil! exe 's/^//=' . strpart((line('.')-line("'<")+1)." ", 0, 4) else sil! exe '%s/^//=' . strpart(line('.')." ", 0, 4) endif endf " add line number befor each line of the text " :g/^/exec "s/^/".strpart(line(".")." ", 0, 4) " :%s/^//=strpart(line('.')." ", 0, 4) " visual mode " :s/^//=strpart((line('.')-line("'<")+1)." ", 0, 4) " XML support, e.g. element,,,<CR> -> <element> </element> " Bart van Deenen , www.vandeenensupport fu! MakeElement() if match(getline('.'),'^/s*>/s*$') == -1 "the deleted word was not alone on the line let @w = "i<pla</pa>F<i" else "the deleted word was on it's own on the line let @w = "i<po</pa>kA" endif endf " include colon(5Cool for namespaces in xsl for instance "setlocal iskeyword=@,48-57,_,192-255,58 inoremap <buffer> ,,, ><Esc>db:call MakeElement()<enter>@w "------------------------------------------------------------------------------------- " mappings "------------------------------------------------------------------------------------- map <right> <ESC>:MBEbn<RETURN> " -> switches buffers map <left> <ESC>:MBEbp<RETURN> " <- switches buffers map <up> <ESC>:Sex<RETURN><ESC><C-W><C-W> " up arrow to bring up a file explorer map <down> <ESC>:Tlist<RETURN> " down arrow to bring up the taglist map <A-i> i <ESC>r " Alt-i inserts a single char, and back to normal map <F3> <ESC>ggVG:call SuperRetab()<left> map <F4> ggVGg? " Rot13 encode the current file "noremap <silent> <C-F11> :cal VimCommanderToggle()<CR> " plugin - php_console.vim "map <F5> :call ParsePhpFile()<cr> " call function in normal mode "imap <F5> <ESC>:call ParsePhpFile()<cr> " call function in insert mode "------------------------------------------------------------------------------------- " autocommands "------------------------------------------------------------------------------------- au BufEnter * :syntax sync fromstart " ensure every file does syntax highlighting (full) au BufNewFile,BufRead *.asp :set ft=jscript " all my .asp files ARE jscript au BufNewFile,BufRead *.tpl :set ft=html " all my .tpl files ARE html " ftplugin - python_fold - $VIMFILES/ftplugin/python_fold.vim " add names in pydiction to autocomplete class or object's class, attribute or method au FileType python set complete+=k$VIMFILES/dict/pydiction isk+=.,( "au FileType python pyfile $VIMFILES/plugin/pyCallTips.py au FileType python source $VIMFILES/plugin/python.vim "au FileType java source $VIMFILES/ftplugin/JavaRun.vim "au FileType php set complete+=k$VIMFILES/dict/php.dict isk+=.,( au FileType text setlocal textwidth=78 "------------------------------------------------------------------------------------- " highlight active line in normal mode, Vim7 don't need this "------------------------------------------------------------------------------------- "highlight CurrentLine guibg=darkgrey guifg=white ctermbg=darkgrey ctermfg=white "au! Cursorhold * exe 'match CurrentLine //%' . line('.') . 'l.*/' "set ut=19 "------------------------------------------------------------------------------------- " stuffs I don't like "------------------------------------------------------------------------------------- "set ignorecase -- turns out, I like case sensitivity "set list -- turns out, do not display unprintable characters such as Tab "autocmd GUIEnter * :simalt ~x -- having it auto maximize the screen is annoying "autocmd BufEnter * :lcd %:p:h -- switch to current dir (breaks some scripts) "------------------------------------------------------------------------------------- " useful abbrevs "------------------------------------------------------------------------------------- iab xasp <%@language=jscript%><CR><%<CR><TAB><CR><BS>%><ESC><<O<TAB> iab xdate <c-r>=strftime("%m/%d/%y %H:%M:%S")<cr> "------------------------------------------------------------------------------------- " customize cursor color to indicate IM is on "------------------------------------------------------------------------------------- if has('multi_byte_ime') hi Cursor guifg=NONE guibg=Green hi CursorIM guifg=NONE guibg=Blue endif "------------------------------------------------------------------------------------- " TVO defaults - otl.vim "------------------------------------------------------------------------------------- let otl_install_menu =1 let no_otl_maps =0 let no_otl_insert_maps =0 let otl_bold_headers =0 let otl_use_thlnk =0 let g:otl_use_viki =0 let maplocalleader ="," map <c-w><c-f> :FirstExplorerWindow<cr> map <c-w><c-b> :BottomExplorerWindow<cr> map <c-w><c-t> :WMToggle<cr> let g:winManagerWidth = 35 let g:winManagerWindowLayout = 'TodoList' let g:tskelDir = $VIMFILES."/skeletons" "------------------------------------------------------------------------------------- " vim: set et ft=vim tw=98 path+=$VIMFILES/*: |
参考:
<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>