12

I'm using the Taglist and NerdTree plugins quite often. Usually the window that opens in the left side is too small and I need to extend it.

I usually do: 10 CTRL+w >

Is there a way to change the default width of the window of NerdTree and Taglist?

  • I do like that key combo though. Could you map that to a command? – Pred Jun 21 '18 at 13:15
14

The examples below set the width to 60 columns. Adjust to your preferences.

NERDTree

NERDTree uses a variable for just this:

:let g:NERDTreeWinSize=60

This will set the width to 60. You can put this line into your vimrc.

Taglist

For taglist, you set a similar option:

:let g:Tlist_WinWidth=60

Like with NERDTree, you can put this line into your vimrc.

Others

Unfortunately there is no generally applicable method. Many plugins do (or should) offer a parameter for this (like above). Others allow you to apply a workaround by setting things you can key off of for an autocommand (such as the filetype, for example, if NERDTree didn't offer the option to set it, you could have done :au FileTupe nerdtree :vert resize 60, since NERDTree sets the filetype on the buffer). I've found that trying to do an autocmd on the WinEnter event based on the buffer name doesn't generally work when the buffer is created, but does if you leave the window and come back to it; plugins often create the window before setting up the buffer. You'll have to experiment with other plugins or request the plugin author to add a parameter.

  • NERDTree defines a configuration variable too, it's NERDTreeWinSize. – toro2k Feb 15 '15 at 19:00
  • @toro2k Right you are sir! I looked through the options list and I couldn't find it. I'm updating my answer. – John O'M. Feb 16 '15 at 0:53
  • ^ That should have read "I looked through the options list and couldn't find anything related to size when I originally wrote the answer" – John O'M. Feb 16 '15 at 1:06
3

I have this problem all the time with splits not being tall enough so I've added this key binding to my .vimrc:

" open the current split all the way
map <c-o> :res 100<CR>

You can adapt this to make the split wider by using :vertical resize. For example,

map <c-o> :vertical resize +10

which will increase the vertical size of the split by 10 columns when you type Control + o.

HTH

  • 1
    There are already Normal mode mappings for maximizing the window in one dimension: <C-W>| for horizontal and <C-W>_ for vertical. – tommcdo Feb 13 '15 at 23:24
  • 1
    This is a nice trick, so that why I +1 it. but it doesn't give a solution to my problem. open the window in specific size as default. – stdcall Feb 14 '15 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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