So, for example in tmux you can hold Ctrl+b and move the separation line with the arrow keys.

Is there any way to do this with NERDTree without using a longer, somewhat discrete command every time?

  • 2
    This might be sacrilegious, but have you thought about using the mouse? :set mouse=a. See :h 'mouse' May 12, 2017 at 16:54
  • 1
    Yes, I have, but was interested with the keyboard for.. you know..reasons.
    – MattSom
    May 13, 2017 at 13:47

2 Answers 2


In Vim you can press Ctrl+w, < or > to decrease and increase window width, respectively. Add comfortable mappings for you, I use the arrow keys, as follows:

nnoremap <Up>    :resize +2<CR>
nnoremap <Down>  :resize -2<CR>
nnoremap <Left>  :vertical resize +2<CR>
nnoremap <Right> :vertical resize -2<CR>

Also, I enjoy this little snippet to create a useful quick resize toggle shortcut within NERDTree:

function! s:SID()
    if ! exists('s:sid')
        let s:sid = matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')
    return s:sid
let s:SNR = '<SNR>'.s:SID().'_'

call NERDTreeAddKeyMap({
    \ 'key': 'w',
    \ 'callback': s:SNR.'toggle_width',
    \ 'quickhelpText': 'Toggle window width' })

function! s:toggle_width()
    let l:max = 0
    for l:z in range(1, line('$'))
        let l:len = len(getline(l:z))
        if l:len > l:max
            let l:max = l:len
    exe 'vertical resize '.(l:max == winwidth('.') ? g:NERDTreeWinSize : l:max)

With this, you can press w on NERDTree buffer to toggle width resize, I find it quite useful.


I found these more intuitive and useful after trying Rafi's answer

nnoremap <Up>    <C-w>+
nnoremap <Down>  <C-w>-
nnoremap <Left>  <C-w><
nnoremap <Right> <C-w>>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.