Skip to content

Instantly share code, notes, and snippets.

@philipmat
Forked from scrooloose/custom_maps.vim
Created February 15, 2012 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philipmat/1835019 to your computer and use it in GitHub Desktop.
Save philipmat/1835019 to your computer and use it in GitHub Desktop.
Couple of custom key maps for nerdtree
if exists("g:loaded_nerdtree_custom_maps")
finish
endif
let g:loaded_nerdtree_custom_maps = 1
"adds a new keymapping on 'gT' that opens the selected file in a bg tab and
"closes the tree
call NERDTreeAddKeyMap({
\ 'scope': 'FileNode',
\ 'key': 'T',
\ 'callback': 'NERDTreeCustomMapsOpenInBgTab',
\ 'quickhelpText': 'open in bg tab and close tree' })
call NERDTreeAddKeyMap({
\ 'scope': 'FileNode',
\ 'key': 't',
\ 'callback': 'NERDTreeCustomMapsOpenInFgTab',
\ 'quickhelpText': 'open current file and close tree' })
"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! NERDTreeCustomMapsOpenInFgTab(fnode)
call a:fnode.open({'where' : 't'})
NERDTreeClose
endfunction
function! NERDTreeCustomMapsOpenInBgTab(fnode)
call a:fnode.open({'where' : 't', 'stay' : 1, 'keepopen' : 1})
"NERDTreeClose
endfunction
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment