Home Ask Login Register

Developers Planet

Your answer is one click away!

divramod February 2016

programatically change NERDTreeWinSize

i like to change the vim-plugin NERDTreeWinSize Variable programmatically.

I added the following function to my vimrc but nothing is happening when i call the function. Any hints?

fun! NerdTreeWinSize( arg )
  let g:NERDTreeWinSize=a:arg
command! -nargs=* Ntws call NerdTreeWinSize( '<args>' )

i can call the function via :Ntws 200 and wish that the NERDTreeWinSize changes to 200 then.

i also realized that nothing is happening when i run let g:NERDTreeWinSize=100 in the vim command line.

But when i add the line let g:NERDTreeWinSize=100 to my vimrc vim adapts the NERDTreeWinSize.


Ingo Karkat February 2016

Your code is correct, and (at least my version of NERDTree) re-evaluates the g:NERDTreeWinSize variable when building its UI. However, the change does not affect open NERDTree windows, only new ones. So, you need to re-open NERDTree for the changes to take effect, maybe via

command! -nargs=* Ntws call NerdTreeWinSize( '<args>' ) | NERDTree

Post Status

Asked in February 2016
Viewed 1,297 times
Voted 9
Answered 1 times


Leave an answer

Quote of the day: live life