Skip to content

Instantly share code, notes, and snippets.

@asgeo1
Forked from scrooloose/hax0r.vim
Created January 5, 2012 23:54
Show Gist options
  • Save asgeo1/1568062 to your computer and use it in GitHub Desktop.
Save asgeo1/1568062 to your computer and use it in GitHub Desktop.
NERDTree custom mappings to make i and s reuse existing windows
let g:NERDTreeCustomReuseWindows = '1'
call NERDTreeAddKeyMap({
\ 'key': 'w',
\ 'scope': 'all',
\ 'callback': 'NERDTreeCustomToggleReuse',
\ 'quickhelpText': 'Toggle use existing windows' })
function! NERDTreeCustomToggleReuse()
let g:NERDTreeCustomReuseWindows = g:NERDTreeCustomReuseWindows ? 0 : 1
echomsg (g:NERDTreeCustomReuseWindows ? 'Reusing' : 'Not reusing') . ' existing windows'
endfunction
call NERDTreeAddKeyMap({
\ 'key': 'i',
\ 'scope': 'FileNode',
\ 'callback': 'NERDTreeCustomOpenSplit',
\ 'quickhelpText': 'open split reusing if able' })
function! NERDTreeCustomOpenSplit(node)
call a:node.open({'split': 'h', 'reuse': (g:NERDTreeCustomReuseWindows ? 1 : 0)})
endfunction
call NERDTreeAddKeyMap({
\ 'key': 's',
\ 'scope': 'FileNode',
\ 'callback': 'NERDTreeCustomOpenVSplit',
\ 'quickhelpText': 'open vsplit reusing if able' })
function! NERDTreeCustomOpenVSplit(node)
call a:node.open({'split': 'v', 'reuse': (g:NERDTreeCustomReuseWindows ? 1 : 0)})
endfunction
call NERDTreeAddKeyMap({
\ 'key': 't',
\ 'scope': 'FileNode',
\ 'callback': 'NERDTreeCustomOpenInTab',
\ 'quickhelpText': 'open in new tab reusing if able' })
function! NERDTreeCustomOpenInTab(node)
call a:node.open({'split': 't', 'reuse': (g:NERDTreeCustomReuseWindows ? 1 : 0)})
endfunction
call NERDTreeAddKeyMap({
\ 'key': 'T',
\ 'scope': 'FileNode',
\ 'callback': 'NERDTreeCustomOpenInTabSilent',
\ 'quickhelpText': 'open in new background tab reusing if able' })
function! NERDTreeCustomOpenInTabSilent(node)
call a:node.open({'split': 'T', 'reuse': (g:NERDTreeCustomReuseWindows ? 1 : 0)})
endfunction
@FrankFang
Copy link

Where to put this file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment