2008年12月25日星期四

gvim for windows:我的_vimrc

vim太让人习惯了,这么好用的编辑器,在windows下也只好继续妥协 :)
我的gvim for windows的_vimrc:

set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

"================liuhongdan===============
"Toggle Menu and Toolbar F2隐藏菜单栏
"http://liyanrui.is-programmer.com/articles/1791/gvim-menu-and-toolbar-toggle.html
set guioptions-=m
set guioptions-=T
map <silent> <F2> :if &guioptions =~# 'T' <Bar>
        \set guioptions-=T <Bar>
        \set guioptions-=m <bar>
    \else <Bar>
        \set guioptions+=T <Bar>
        \set guioptions+=m <Bar>
    \endif<CR>

colorscheme torte                   "配色,找了好长时间
set cindent                        
set nobackup        
set foldmethod=syntax            "默认使用语法折叠
set tags=tags;
set autochdir
let Tlist_Ctags_Cmd = 'ctags'    "ctags.exe放在vim安装目录
let Tlist_Show_One_File = 1      "只显示一个taglist窗口
let Tlist_Exit_OnlyWindow = 1    "vim退出时taglist也退出
:nmap <C-t> :tabnew .<CR>     "Ctrl+t新建标签
:nmap <F5> :tabprevious<CR>   "F5前一个标签
:nmap <F6> :tabnext<CR>        "F6后一个标签
:nmap <F4> :TlistToggle<CR>    "F4打开taglist窗口
"================liuhongdan===============

set diffexpr=MyDiff()
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


说明:
1.taglist的安装和linux下一样,下载taglist(http://www.vim.org/scripts/script.php?script_id=273)解压缩复制,按照文档来就行了
2.taglist需要ctags支持,下载ctags for windows(http://ctags.sourceforge.net/),有一个ec57w32.zip,将里面的ctags.exe复制到vim的安装文件夹就行了,和其它的exe在一起,我的vim默认安装,路径为C:\Program Files\Vim, C:\Program Files\Vim\vim72里面是那些主程序.
3.:nmap <C-t> :tabnew .<CR>     "Ctrl+t新建标签,这里有一个".",打开当前文件夹内容,可直接选择文件打开,面的还要自己用鼠标去点文件了.
4.只是为了暂时应急,所以这些功能足够了^_^

没有评论: