Skip to content

Instantly share code, notes, and snippets.

@colindresj
Last active February 23, 2018 01:13
Show Gist options
  • Save colindresj/d4b31211d6df346e48b4f47509b4548a to your computer and use it in GitHub Desktop.
Save colindresj/d4b31211d6df346e48b4f47509b4548a to your computer and use it in GitHub Desktop.
nerdtree_plugin/toggle_width
" put this script in ~/.vim/nerdtree_plugin/
call NERDTreeAddKeyMap({
\ 'key': 'w',
\ 'callback': 'NERDTreeToggleWidth',
\ 'quickhelpText': 'Toggle window width' })
function! NERDTreeToggleWidth()
let l:maxi = 0
for l:z in range(1, line("$"))
let l:aktlen = len(getline(l:z))
if l:aktlen > l:maxi
let l:maxi = l:aktlen
endif
endfor
exe "vertical resize " . (l:maxi == winwidth(".") ? g:NERDTreeWinSize : l:maxi)
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment