Skip to content

Commit 7f81e0c

Browse files
committed
Add horizontal position options to g:NERDTreeWinPos (#1363)
1 parent bce2669 commit 7f81e0c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

doc/NERDTree.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ setting is used.
11281128

11291129
------------------------------------------------------------------------------
11301130
*NERDTreeWinPos*
1131-
Values: "left" or "right"
1131+
Values: "left", "right", "top" or "bottom"
11321132
Default: "left".
11331133

11341134
This setting is used to determine where NERDTree window is placed on the
@@ -1138,6 +1138,13 @@ This setting makes it possible to use two different explorer plugins
11381138
simultaneously. For example, you could have the taglist plugin on the left of
11391139
the window and the NERDTree on the right.
11401140

1141+
When setting this variable to "top" or "bottom" make sure to also change the
1142+
|NERDTreeWinSize| to a more reasonable size.
1143+
1144+
For example:
1145+
>
1146+
let g:NERDTreeWinSize = 15
1147+
<
11411148
------------------------------------------------------------------------------
11421149
*NERDTreeWinSize*
11431150
Values: a positive integer.

lib/nerdtree/creator.vim

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,17 @@ endfunction
182182
" Initialize the NERDTree window. Open the window, size it properly, set all
183183
" local options, etc.
184184
function! s:Creator._createTreeWin()
185-
let l:splitLocation = g:NERDTreeWinPos ==# 'left' ? 'topleft ' : 'botright '
185+
let l:splitLocation = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'top' ? 'topleft ' : 'botright '
186+
let l:splitDirection = g:NERDTreeWinPos ==# 'left' || g:NERDTreeWinPos ==# 'right' ? 'vertical' : ''
186187
let l:splitSize = g:NERDTreeWinSize
187188

188189
if !g:NERDTree.ExistsForTab()
189190
let t:NERDTreeBufName = self._nextBufferName()
190-
silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' new'
191+
silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' new'
191192
silent! execute 'edit ' . t:NERDTreeBufName
192-
silent! execute 'vertical resize '. l:splitSize
193+
silent! execute l:splitDirection . ' resize '. l:splitSize
193194
else
194-
silent! execute l:splitLocation . 'vertical ' . l:splitSize . ' split'
195+
silent! execute l:splitLocation . l:splitDirection . ' ' . l:splitSize . ' split'
195196
silent! execute 'buffer ' . t:NERDTreeBufName
196197
endif
197198

0 commit comments

Comments
 (0)