Nerdtree: Nerdtree window automatically resize to fit contents?

Created on 18 Jul 2018  路  2Comments  路  Source: preservim/nerdtree

Environment

  • Operating System: Mac OS X
  • Vim version VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 29 2017 18:37:46):
  • NERDTree version a0e49c9:
  • NERDTree settings applied in your vimrc, if any:
    vim autocmd vimenter * NERDTree let NERDTreeMinimalUI = 1 let NERDTreeDirArrows = 1 autocmd FileType nerdtree nnoremap <buffer> s j let g:NERDTreeMapOpenSplit = 'q' let g:NERDTreeMapOpenVSplit = 'e' autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

The default size of the split NERDTree uses is small -- that's usually a good thing, except for when you're exploring deep directory structures with long filenames. If you have set nowrap filenames can get lost off the side of the split.

I'd like NERDTree to resize its split when directories are expanded to make sure the contents are visible. Is there a standard snippet for this?

Most helpful comment

It's not automatic, but you can use the A key to maximize the NERDTree window, and A again to restore it to its original size. You can also change the size of the window with the NERDTreeWinSize setting, which defaults to 31 characters.

See :h NERDTreeWinSize and :h NERDTree-A.

All 2 comments

It's not automatic, but you can use the A key to maximize the NERDTree window, and A again to restore it to its original size. You can also change the size of the window with the NERDTreeWinSize setting, which defaults to 31 characters.

See :h NERDTreeWinSize and :h NERDTree-A.

I think you're expecting your editor to do a bit too much here. If you want, you can try to write your own NERDTree plugin with a buffer-local autocommand to do the work. I'm against adding this kind of feature to the NERDTree because it means adding a fair amount of of new code (and thus bugs) and a new global option to control the feature. This is not really the kind of addition we're looking for. Good luck!

Was this page helpful?
0 / 5 - 0 ratings