Created
December 28, 2011 10:33
-
-
Save scrooloose/1527501 to your computer and use it in GitHub Desktop.
Couple of custom key maps for nerdtree
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
if exists("g:loaded_nerdtree_custom_maps") | |
finish | |
endif | |
let g:loaded_nerdtree_custom_maps = 1 | |
"adds a keymapping on 'o' that overrides the standard nerdtree 'o' mapping and | |
"to open the file node and close the tree | |
call NERDTreeAddKeyMap({ | |
\ 'key': 'o', | |
\ 'callback': "NERDTreeCustomMapsOpenAndClose", | |
\ 'quickhelpText': 'open current file and close tree' }) | |
function! NERDTreeCustomMapsOpenAndClose() | |
let n = g:NERDTreeFileNode.GetSelected() | |
if n != {} | |
if !n.path.isDirectory | |
call n.open() | |
NERDTreeClose | |
else | |
" if the node is a dir then just activate it as norm | |
call n.activate(0) | |
endif | |
endif | |
endfunction | |
"adds a new keymapping on 'gT' that opens the selected file in a bg tab and | |
"closes the tree | |
call NERDTreeAddKeyMap({ | |
\ 'key': 'gT', | |
\ 'callback': "NERDTreeCustomMapsOpenInNewTabAndClose", | |
\ 'quickhelpText': 'open in bg tab and close tree' }) | |
function! NERDTreeCustomMapsOpenInNewTabAndClose() | |
let n = g:NERDTreeFileNode.GetSelected() | |
if n != {} | |
call n.openInNewTab({'stayInCurrentTab': 1}) | |
NERDTreeClose | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment