我刚刚使用 vundle 在 vim 中安装了 NERDTree 和 Tagbar。当我一次使用一个插件时一切正常,但是当我尝试打开一个而另一个已经打开时会导致问题。
这是打开NERDTree的vim图
+------+---------------+
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
+------+---------------+
在我打开 NERDTree 打开标签栏之后
++---------------+------+
|| | |
|| | |
|| | |
|| | |
|| | |
|| | |
|| | |
|| | |
+--+-------------+------+
NERDTree 现在向左挤压。
如果我尝试切换 NERDTree,它会一直被压扁,直到我切换标签栏。有什么特别的事情我必须做才能让这两个很好吗?
vim 非常新,所以除了我使用 vim 7.4 之外不确定要提供什么信息,我不确定如何找到我正在使用的插件的版本。
我的 .vimrc 是
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'fatih/vim-go'
Plugin 'majutsushi/tagbar'
Plugin 'fatih/molokai'
Plugin 'tmhedberg/SimpylFold'
Plugin 'Valloric/YouCompleteMe'
Plugin 'bling/vim-airline'
Plugin 'scrooloose/syntastic'
Plugin 'nsf/gocode', {'rtp': 'vim/'}
Plugin 'scrooloose/nerdtree'
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
Plugin 'flazz/vim-colorschemes'
Plugin 'kien/ctrlp.vim'
call vundle#end()
filetype plugin indent on
"Ok. Done.
set backspace=indent,eol,start
set number
set nowrap
set hidden
inoremap jk <ESC>
let mapleader=","
" we also want to get rid of accidental trailing whitespace on save
autocmd BufWritePre * :%s/\s\+$//e
" =================================================
" ----------
" Navigation
" ----------
" tell vim to allow you to copy between files, remember your cursor
" position and other little nice things like that
" split navigations
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" =================================================
" -------------
" Golang Config
" -------------
" tell vim to allow you to copy between files, remember your cursor
" position and other little nice things like that
set viminfo='100,\"2500,:200,%,n~/.viminfo
" Open file at a position where it was last left.
au BufWinLeave *.go mkview
au BufWinEnter *.go silent loadview
" use goimports for formatting
let g:go_fmt_command = "goimports"
" turn highlighting on
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
" =================================================
" ---------
" Syntastic
" ---------
let g:syntastic_go_checkers = ['go', 'golint', 'errcheck']
" we want to tell the syntastic module when to run
" we want to see code highlighting and checks when we open a file
" but we don't care so much that it reruns when we close the file
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" Open go doc in vertical window, horizontal, or tab
au Filetype go nnoremap <leader>v :vsp <CR>:exe "GoDef" <CR>
au Filetype go nnoremap <leader>s :sp <CR>:exe "GoDef"<CR>
au Filetype go nnoremap <leader>t :tab split <CR>:exe "GoDef"<CR>
" =================================================
" -----------
" Color setup
" -----------
set t_Co=256
syntax enable
set background=dark
try
colorscheme distinguished
catch E185
endtry
" =================================================
" -------
" Airline
" -------
" display fonts correctly for airline
set encoding=utf-8
" Allows the bottom status line for airline to be shown
set laststatus=2
let g:airline_powerline_fonts=1
" Enable the list of buffers
let g:airline#extensions#tabline#enabled = 1
" Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
" =================================================
" --------
" NerdTree
" --------
map <C-n> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
let g:NERDTreeWinSize = 40
" =================================================
" ----
" Tmux
" ----
" let g:tmux_navigator_save_on_switch = 1
" =================================================
" -----------
" CodeFolding
" -----------
" Enable folding
set foldmethod=indent
set foldlevel=99
" Enable folding with the spacebar
nnoremap <space> za
" =================================================
" ------
" TagBar
" ------
nmap <silent> <leader>tt :TagbarToggle<CR>
let g:tagbar_autoclose = 0
let g:tagbar_left = 0
let g:tagbar_expand = 0
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
" =================================================
" ------
" Ctrl-P
" ------
set wildignore+=*/tmp/*,*.so,*.swp,*.zip
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_user_command = 'find %s -type f'
" NERDTree and TagBar don't play nicly together, when one is open and then
" open another one the inital one gets squished this will toggle one or the
" other only having one open at a time
function! ToggleNERDTreeAndTagbar()
" let w:jumpbacktohere = 1
" Detect which plugins are open
if exists('t:NERDTreeBufName')
let nerdtree_open = bufwinnr(t:NERDTreeBufName) != -1
else
let nerdtree_open = 0
endif
let tagbar_open = bufwinnr('__Tagbar__') != -1
" Perform the appropriate action
if nerdtree_open && tagbar_open
NERDTreeClose
TagbarClose
elseif nerdtree_open
NERDTreeClose
TagbarOpen
elseif tagbar_open
TagbarClose
NERDTree
else
NERDTree
endif
" Jump back to the original window
" for window in range(1, winnr('$'))
" execute window . 'wincmd w'
" if exists('w:jumpbacktohere')
" unlet w:jumpbacktohere
" break
" endif
" endfor
endfunction
nnoremap <leader>\ :call ToggleNERDTreeAndTagbar()<CR>