I have just installed NERDTree and Tagbar in vim using vundle. Everything works fine when I use one plugin at a time but when I try and open one while having the other one already open causes problem.
Here's a diagram of vim with NERDTree open
+------+---------------+
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
+------+---------------+
and after I open Tagbar with NERDTree open
++---------------+------+
|| | |
|| | |
|| | |
|| | |
|| | |
|| | |
|| | |
|| | |
+--+-------------+------+
NERDTree is now squished to the left.
If I try and toggle NERDTree, it stays squished until I toggle tagbar. Is there something special that I have to do to get the two to place nice?
Very new to vim so not sure what information to give other than I'm using vim 7.4 and I'm not sure how to find the versions of the plugins I'm using.
My .vimrc is
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>
In case anyone else comes across this problem. The solution for me was to remove this line
au BufWinEnter *.go silent loadview