您的位置:首页 > 其它

windows & 下的VIM+ctags+taglist

2011-06-30 16:16 393 查看
下载gvim72.exe 并安装,默认的目录在C:\Program Files\Vim\ 其中C:\Program Files\Vim\vimfiles\ 目录就相当于linux中的家目录的.vim/目录,插件,配色方案什么的的直接放里面.
下载ctags58.zip (ctags)连接Ctags
解压缩后ctags.exe到 C:\windows\system32\ .只要是放在环境变量(%path%)目录中都可以.
下载taglist,把文件分别放置到:
1. plugin/taglist.vim – taglist插件 
2. doc/taglist.txt    - taglist帮助文件 .
顺便贴下自己的.vimrc文件
"plugin
"{
"require Exuberant ctags for the taglist.vim sudo apt-get install exuberant-ctags
"taglist :Source code browser (supports C/C++, java, perl, python, tcl, sql,php, etc)
"http://www.vim.org/scripts/script.php?script_id=273
"TxtBrowser : Browse plain text easily (show the title tag and syntax highlight)
"http://www.vim.org/scripts/script.php?script_id=2899
"sippmate
"http://www.vim.org/scripts/script.php?script_id=2540
"The NERD tree : A tree explorer plugin for navigating the filesystem
"http://www.vim.org/scripts/script.php?script_id=1658
"Supertab aims to provide tab completion to satisfy all your insert completion needs
":SuperTabHelp command which opens a temporary buffer listing all the available types and the ability to easily switch to that type.
"MRU : Most recently used files in your file menu
"http://www.vim.org/scripts/script.php?script_id=194
"python.vim : for adjust the indent performance for python file
"http://www.vim.org/scripts/script.php?script_id=974
"}
"sudo apt-get install vim-gnome
"make you can use the system clipboard "+p { the selection content "*p }
"""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""".
"The search options affect
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
" 匹配括号高亮的时间(单位是十分之一秒)
set matchtime=5
set hls
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
"set lazyredraw
command! -nargs=1 Silent
\ | execute ':silent !'.<q-args>
\ | execute ':redraw!'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"The simple look like
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nu "set number
syntax on
set background=dark
"set cursorline
"set cursorcolumn " highlight the current column
set mouse=a " Enable mouse usage (all modes)
set scrolloff=3 "始终保持光标上下有至少3行
set scrolljump=5 "lines to scroll when cursor leaves screen
"command line set
"{
set laststatus=2 " always show the status line
set wildmenu
set wildmode=list:longest,full
" ignore these list file extensions
set wildignore=*.dll,*.o,*.obj,*.exe,*.pyc,\*.jpg,*.gif,*.png,*.pdf
"设置状态行,使其能额外显示文件的编码信息
"set statusline=\ %F\ [buffer:%n]\ \ %m%<%r\ \ \ \ %10l/%L:%c\->%p%%\ \ [%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",bom\":\"\")}]\ \ \ [%{&ff}/%Y]%=\ PWD:%{CurDir()}
set statusline=\ %F\ %m%<%r\ \ %10l/%L:%c\->%p%%\ \ [%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",bom\":\"\")}]\ \ \ [%{&ff}/%Y]%=\ PWD:%{CurDir()}
function! CurDir()
let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
return curdir
endfunction
"}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"the map leader shortcut and the keymap
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader = ","
let g:mapleader = ","
noremap <space> :
noremap <leader>= gg=G
inoremap <leader>w <ESC>:w<CR>
inoremap <leader>q <ESC>:q<CR>
noremap <leader>w :w<CR>
noremap <leader>q :q<CR>
noremap <leader>! :w !sudo tee % >/dev/null<CR>
noremap <leader>b :set wrap!<CR>
noremap <leader>8 :set fileencoding=utf-8<cr>:w<cr>
noremap <leader>r :! ./% <CR>
noremap <leader>e :MRU<CR>
noremap <leader>l :set nohls!<CR>
noremap <leader>h :hide<CR>
noremap <leader>n :NERDTreeToggle<CR>
noremap <leader>t :TlistToggle<CR>
noremap <leader>m :mksession! Session.vim
noremap = <c-w>10+
noremap - <c-w>10-
noremap <leader>> <c-w>10>
noremap <leader>< <c-w>10<
noremap <C-n> gt
noremap <C-p> gT
noremap tc :tabclose<CR>
noremap tn :tabedit
noremap tm :tabmove<CR>
inoremap jj <ESC>:w<CR>
cnoremap jj <ESC>
"tab键缩进
nmap <tab> V>
nmap <S-tab> V<
vmap <tab> >gv
vmap <S-tab> <gv
"move the cursor between the windows
"多个窗口的切换
set wmw=12 " set the min width of a window to 0 so we can maximize others
set wmh=1 " set the min height of a window to 0 so we can maximize others
" --- move around splits {
" move to and maximize the below split
nnoremap <C-j> <C-W>j<C-W>8+
" move to and maximize the above split
nnoremap <C-k> <C-W>k<C-W>8+
" move to and maximize the left split
"nmap <c-h> <c-w>h<c-w><bar>
nnoremap <c-h> <c-w>h<c-w>8>
" move to and maximize the right split
nnoremap <c-l> <c-w>l<c-w>8>
"nmap <c-l> <c-w>l<c-w><bar>
"nnoremap <C-j> :wincmd j<CR>
"nnoremap <C-k> :wincmd k<CR>
"nnoremap <C-h> :wincmd h<CR>
"nnoremap <C-l> :wincmd l<CR>
" 在文件名上按gf时,在新的tab中打开
map gf :tabnew <cfile><cr>
"the shortcut for cmdline
cnoremap <C-A> <Home>
cnoremap <C-E> <End>
cnoremap <C-K> <C-U>
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
cnoremap <C-F> <Right>
cnoremap <C-B> <Left>
cnoremap <C-D> <del>
cnoremap <C-H> <backspace>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 文本格式和排版
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"the plugin setup
filetype plugin on
filetype plugin indent on
set sw=4 "set softswitch to 4
set tabstop=4 "set tab to 4
set softtabstop=4
set expandtab "expand tab to 4 space
set virtualedit=onemore " allow for cursor beyond last character
set shortmess+=filmnrxoOtT " abbrev. of messages (avoids 'hit enter')
"set text
set autoindent
set smartindent
"set cindent " C/C++风格缩进
set nowrap " Set no auto newline
set iskeyword+=_,$,@,%,#,- " 带有如下符号的单词不要被换行分割
"set linebreak "设置是否自动断行
set smarttab " 只在行和段开始处使用制表符,其他位置扩展成空格
set backspace=2 " 使回格键(backspace)正常处理indent, eol, start等
set nocompatible
set history=1000
set viminfo+=! " make sure it can save viminfo 确保命令历史被记录在viminfo文件中.
set autoread " Set to auto read when a file is changed from the outside
set autowrite " Automatically save before commands like :next and :make
set autochdir "Auto change the global dir of the current windows
" 设置字符集编码,默认使用utf8
if (has("win32") || has("win64") || has("win32unix"))
let g:isWin = 1
else
let g:isWin = 0
endif
if (g:isWin)
set encoding=utf-8
set termencoding=utf-8
set fileencodings=ucs-bom,utf-8,chinese,gb2312
set langmenu=zh_CN.utf-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
language messages zh_cn.utf-8
set swapfile
set backup " backups are nice ...
set background=dark
"set guifont=Courier_New:h10:cANSI "英文字体 字符集可以省略不写
set guifont=Lucida_Sans_Typewriter:h10.5w6.3:cANSI "英文字体 字符集可以省略不写.空格用_代替,h字高,w字宽.float型
set guifontwide="幼圆:h11w2:cGB2312" "中文字体,字体大小,字符集
else
"the backup file and swap file in the specified directory
"{
set swapfile
set backup " backups are nice ...
set backupdir=$HOME/.vimbackup// " but not when they clog .
set directory=$HOME/.vimswap// " Same for swap files
"Creating directories if they don't exist
silent execute '!mkdir -p $HOME/.vimbackup'
silent execute '!mkdir -p $HOME/.vimswap'
set encoding=utf8
set fileencodings=utf8,gb2312,gb18030,ucs-bom,latin1
endif
"新文件编码
set fileencoding=utf-8
" No sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
if has("gui_running")
let g:isGUI = 1
set guioptions=
set guitablabel=%N:\ %f "tab栏显示的格式:位置:文件名
set t_Co=256
set background=dark
set linespace=5 "row space.
set linespace=3 "row space.(两行的间距, 只对gvim有效.)
"Ctrl+S实现保存,如果未命名文件名会提示你选择保存路径和文件名
map <silent> <C-S> :if expand("%") == ""<CR>:browse confirm w<CR>:else<CR>:confirm w<CR>:endif<CR>
noremap <M-1> 1gt
noremap <M-2> 2gt
noremap <M-3> 3gt
noremap <M-4> 4gt
noremap <M-5> 5gt
noremap <M-6> 6gt
noremap <M-7> 7gt
noremap <M-8> 8gt
noremap <M-9> 9gt
else
let g:isGUI = 0
endif
if (g:isGUI)
set cursorline
"set guifont=DejaVu\ Sans\ Mono:11
"set guifontwide=文泉驿等宽微米黑:11
hi StatusLine guifg=yellow gui=reverse,bold guibg=black
hi StatusLineNC guifg=lightgray gui=reverse,bold guibg=black
"hi Normal guifg=#d0d0d0 guibg=#202020 gui=NONE
endif
" 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>
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
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
"}
"输入配置
" 关闭中文标点
let g:vimim_disable_chinese_punctuation=1
"中英文之间不加空格
let g:vimim_disable_seamless_english_input=1
" paste from clipboard
noremap <leader>p <ESC>:call Paste()<CR><ESC>
inoremap <leader>p <ESC>:call Paste()<CR><ESC>
noremap <leader>y "+yy
inoremap <leader>y <ESC>"+yy
noremap Y gg"+yG
function! Paste()
execute "set paste"
execute "normal \"+p"
execute "set nopaste"
execute "normal l"
endfunction
function! Yank()
execute "normal \"+yy"
endfunction
"插入模式缩写
iab idate <c-r>=strftime("%Y-%m-%d")<CR>
iab inow <c-r>=strftime("%Y-%m-%d %H:%M")<CR>
iab itime <c-r>=strftime("%H:%M")<CR>
iab igmail lijun877@gmail.com
iab iname LiJunYa
" 恢复上次文件打开位置
set viminfo='10,\"100,:20,%,n~/.viminfo
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
" 快捷输入
" 自动完成括号和引号
"inoremap <leader>1 ()<esc>:let leavechar=")"<cr>i
"inoremap <leader>2 []<esc>:let leavechar="]"<cr>i
"inoremap <leader>3 {}<esc>:let leavechar="}"<cr>i
"inoremap <leader>4 {<esc>o}<esc>:let leavechar="}"<cr>O
"inoremap <leader>q ''<esc>:let leavechar="'"<cr>i
"inoremap <leader>w ""<esc>:let leavechar='"'<cr>i
" Writing Restructured Text (Sphinx Documentation)
"{
" Ctrl-u 1: underline Parts w/ #'s
noremap <C-u>1 yyPVr#yyjp
inoremap <C-u>1 <esc>yyPVr#yyjpA
" Ctrl-u 2: underline Chapters w/ *'s
noremap <C-u>2 yyPVr*yyjp
inoremap <C-u>2 <esc>yyPVr*yyjpA
" Ctrl-u 3: underline Section Level 1 w/ ='s
noremap <C-u>3 yypVr=
inoremap <C-u>3 <esc>yypVr=A
" Ctrl-u 4: underline Section Level 2 w/ -'s
noremap <C-u>4 yypVr-
inoremap <C-u>4 <esc>yypVr-A
" Ctrl-u 5: underline Section Level 3 w/ ^'s
noremap <C-u>5 yypVr^
inoremap <C-u>5 <esc>yypVr^A
"}
"setting options of mksession.
set sessionoptions+=resize,winpos
autocmd VimEnter * call LoadSession()
autocmd VimLeave * call SaveSession()
function! SaveSession()
if (filereadable("Session.vim"))
execute 'mksession!'
endif
endfunction
function! LoadSession()
if argc() == 0
silent! execute 'source Session.vim'
endif
endfunction
"fold save the fold setting automaticlly
"silent execute '!mkdir -p $HOME/.vim/view'
"set viewoptions=folds,options,cursor,unix,slash " better unix / windows compatibility
"au BufWinLeave * silent! mkview
"au BufWinEnter * silent! loadview
"}
set diffopt=filler,vertical " diffsplit {filename} open the $filename in the new windows vertically and compare the with the current file.
"let @#='I<html>A<\hmtl>' " type let @q=' then type <C-R> <C-R> q' store the marco saved in register q. viewing the content of the register q (:reg q)
autocmd! bufwritepost *.vimrc source $HOME/.vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" CTags的设定
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 按照名称排序
let Tlist_Sort_Type = "name"
" 在右侧显示窗口
let Tlist_Use_Right_Window = 1
" 压缩方式 Remove extra information and blank lines from the taglist window.
let Tlist_Compact_Format = 1
" 如果只有一个buffer,kill窗口也kill掉buffer
let Tlist_Exit_OnlyWindow = 1
"auto open Tlist when vim open
let Tlist_Auto_Open = 0
" 不要显示折叠树
let Tlist_Enable_Fold_Column = 0
" taglist 窗口宽度
let Tlist_WinWidth = 22
" no inc the width of the windows
let Tlist_Inc_Winwidth = 1
" Close tag folds for inactive buffers.
let Tlist_File_Fold_Auto_Close = 1
"To process files even when the taglist window is not open.
let Tlist_Process_File_Always = 1
"display the tags defined only in the current buffer
let Tlist_Show_One_File = 1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" NERDTree的设定
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 如果用t T i 打开文件后自动退出NERDTree,
let NERDTreeQuitOnOpen = 1
" 总是显示Bookmark
let NERDTreeShowBookmarks = 1
" 总是显示行号
"let NERDTreeShowLineNumbers=1
" NERDTree 窗口大小
let NERDTreeWinSize = 22
" A 可使NERDTree窗口最大化Toggle it.
"过滤文件,使用正则表达式
let NERDTreeIgnore=['\.pdf$','\.doc','\.wmv','\.flv']
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 自动补全设置supertab snippmate omincomplete
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:SuperTabDefaultCompletionType = "context"
"The current completion type is only retained for the current completion. Once you have chosen a completion
"result or exited the completion mode, the default completion type is restored.
let g:SuperTabRetainCompletionDuration = 'completion' "could be 'insert' 'session'
let g:SuperTabCompletionContexts = ['s:ContextText', 's:ContextDiscover']
set completeopt=menu,preview,longest
let g:SuperTabLongestHighlight = '0' "若设置为1 ,预先选中一个补全选项,可以直接回车使用这个补全选项
let g:SuperTabMidWordCompletion = '1' "启用/禁止在字中间启用completion
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" omincomplete
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"autocmd FileType python set omnifunc=pythoncomplete#Complete
"autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
"autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
"autocmd FileType css set omnifunc=csscomplete#CompleteCSS
"autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
"autocmd FileType php set omnifunc=phpcomplete#CompletePHP
"autocmd FileType c set omnifunc=ccomplete#Complete
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"The Colors
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
colorscheme desert
" 状态行颜色
hi StatusLine guifg=yellow guibg=black gui=reverse,bold "当前窗口的状态栏颜色
hi search ctermfg=black ctermbg=Magenta
hi search guifg=black guibg=Magenta
hi wildmenu ctermbg=magenta
"当前窗口的状态栏颜色
hi StatusLine ctermfg=yellow cterm=bold,reverse
hi modemsg ctermfg=1
"hi CursorLine ctermfg=DarkYellow guibg=DarkYellow
"设置自动补全跳出菜单颜色,pmenusel是选择时的颜色.note:guifg guibg only effected when vim has the gui
hi Pmenu ctermbg=7 ctermfg=0 cterm=reverse
hi PmenuSel ctermbg=Magenta ctermfg=0
hi Pmenu guibg=yellow guifg=black cterm=reverse
hi PmenuSel guifg=black guibg=Magenta
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"TxtBrowser的设定
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
au BufRead,BufNewFile * setfiletype txt
au BufRead,BufNewFile *.log setlocal ft=txt nu
au FileType txt set formatoptions=tcr2mB nocindent text nofoldenable comments&
let g:default_web_browser='firefox'
"若firefox出现,already running cannot open new windows的错误时.先关闭firefox然后删除 "~/.mozilla/firefox/.parentlock 这个文件即可
let TxtBrowser_Title_Level = 3 "定义标题级数
let TxtBrowser_Dict_Url='http://www.iciba.com/text' "定义单词搜索引擎
au filetype txt let Tlist_Sort_Type = "order"
noremap <leader>u <ESC>:w<CR>:TlistUpdate<CR>
noremap <leader>g <ESC>:TGoto<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"文件管理调用
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! Ranger()
" Get a temp file name without creating it
let tmpfile = substitute(system('mktemp -u'), '\n', '', '')
" Launch ranger, passing it the temp file name
silent exec '!RANGER_RETURN_FILE='.tmpfile.' ranger'
" If the temp file has been written by ranger
if filereadable(tmpfile)
" Get the selected file name from the temp file
let filetoedit = system('cat '.tmpfile)
exec 'edit '.filetoedit
call delete(tmpfile)
endif
redraw!
endfunction
nmap <leader>f :call Ranger()<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"程序相关的设定
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"只对c,cpp,java,pl,sh,py格式的文件启动自动缩进.注释进行了自动缩进 fold按缩进程度进行代码块的收放
autocmd FileType python set foldmethod=indent formatoptions=croql cindent comments=sr:/*,mb:*,ex:*/,://
autocmd FileType c,cpp,java,perl,sh set foldmethod=indent formatoptions=croql cindent comments=sr:/*,mb:*,ex:*/,://
"highlight characters after column 80.
autocmd FileType c,cpp :match ErrorMsg /\%>80v.\+/ noremap <leader>r :! ./%< <CR>
set makeprg=gcc\ -Wall\ %\ -o\ %<
" 下述代码在windows下使用会报错需要去掉./这两个字符
" C的编译和运行,编译失败还是会运行,需改进
"{
noremap <leader>c :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
exec "!gcc -Wall % -o %<"
"exec "! ./%<"
endfunc
" C++的编译和运行
map <F6> :call CompileRunGpp()<CR>
func! CompileRunGpp()
exec "w"
exec "!g++ % -o %<"
exec "! ./%<"
endfunc
"}
"你的工作目录下有Makefile文件, 只需输入:make命令就可以进行编译了;
"没有Makefile文件,make的时候会调用 'makeprg'里参数进行编译.
"在quickfix模式里经常用到的命令有:
" :cn 跳到下一个错误 ( :help :cn )
" :cp 跳到上一个错误 ( :help :cp )
" :cl 列出所有错误 ( :help :cl )
" :cw 如果有错误列表, 则打开quickfix窗口 ( :help :cw )
" :col 到前一个旧的错误列表 ( :help :col )
" :cnew 到后一个较新的错误列表 ( :help :cnew )
set cscopequickfix=s-,c-,d-,i-,t-,e-

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: