BumbleBirds
BumbleBirds

Reputation: 45

Resize Splits in Vim after NERDTreeToggle

I am looking for a way to automatically resize my open v-split panes in Vim after I call NERDTreeToggle.

I have NERDTreeToggle being called on the shortcut "ctrl+\" at the moment, and ideally what I want is to call the keyboard shortcut "ctrl+w =" immediately afterwards.

Any ideas? Thanks.

Upvotes: 1

Views: 229

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172698

If this is your current mapping:

:nnoremap <C-\> :NERDTreeToggle<CR>

You can just append the window command after it:

:nnoremap <C-\> :NERDTreeToggle<CR><C-w>=

Alternatively, you can execute this from command-line mode as well, via :normal!:

:nnoremap <C-\> :NERDTreeToggle<Bar>execute "normal! \<lt>C-w>="<CR>

Note that for window commands, there's also a special :wincmd to invoke them:

:nnoremap <C-\> :NERDTreeToggle<Bar>wincmd =<CR>

Upvotes: 2

Related Questions