Open NERDTree and Tlist above each other in Vim
Asked Answered
P

1

3

I'm looking for a way to (automatically) open NERDTree and Tlist on the left side directly above each other, so that each plugin takes up half of the screen height. I already found this question, in which the answer of Mohammed is kind of what I'm looking for. However, I'm wondering if maybe there is a more direct way of doing this.

Photoelectron answered 17/11, 2011 at 19:28 Comment(2)
possible duplicate of Opening a window in a horizontal split of a vertical splitHazan
@Hazan Yeah, of course it's kind of a duplicate. But that question didn't receive a satisfying answer and hasn't seen any activity in a couple of months. So how would I go about reactivating that question, other than extending it to a new one?Photoelectron
C
6

Here's a solution that requires a small edit to the 'taglist.vim' script. I haven't worked out all the potential ramifications, but it seems to work nicely so far. Modify the 'Tlist_Window_Create' function in 'taglist.vim' to include the elseif statement shown here:

...
" Create a new window. If user prefers a horizontal window, then open
" a horizontally split window. Otherwise open a vertically split
" window
if g:Tlist_Use_Horiz_Window
    " Open a horizontally split window
    let win_dir = 'botright'
    " Horizontal window height
    let win_size = g:Tlist_WinHeight
elseif g:Tlist_Use_Split_Window
    " Open the window in a horizontal split  of current window
    let win_dir = 'abo'
    let win_size = g:Tlist_WinWidth
else
...

I inserted this starting at line 1290 in the latest TagList (v4.5). Then add the following to your .vimrc

let Tlist_Use_Split_Window = 1
com TT NERDTree | TlistToggle

Now the :TT command opens the TagList above the NERDTree in a single vertical window. As is it doesn't quite split halfway, but it's close. If you prefer the tree on top change the abo above to split.

Colyer answered 18/11, 2011 at 0:22 Comment(2)
also, the TT you've defined doesn't completely toggle NERDTree-ideally, using TT either way should either open them both, and close them both.Buttonwood
@Adam It looks like if you use NERDTreeToggle instead of NERDTree when defining TT, it will close NERDTree appropriately. However, this only works if you use 'abo' for win_dir. If you use 'split', taglist will complain about the window not being open and open a new window, which messes things up (but if you do use 'split' the windows are split halfway). What I have defined after the TT definition is noremap <S-Space> :TT<CR><C-w>= - this resizes all windows equally on show or hide, but typically this is what I want anyway.Discharge

© 2022 - 2024 — McMap. All rights reserved.