-
-
Save asgeo1/1568062 to your computer and use it in GitHub Desktop.
NERDTree custom mappings to make i and s reuse existing windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where to put this file?