Skip to content

Instantly share code, notes, and snippets.

@AndrewRadev
Created October 10, 2009 14:39
Show Gist options
  • Save AndrewRadev/206863 to your computer and use it in GitHub Desktop.
Save AndrewRadev/206863 to your computer and use it in GitHub Desktop.
NERDTree integration with Utl
" Requires: Utl
call NERDTreeAddKeyMap({
\ 'key': 'gu',
\ 'callback': 'OpenCurrentNodeWithUtl',
\ 'quickhelpText': 'open current node with the Utl plugin' })
function! OpenCurrentNodeWithUtl()
" Get the path of the item under the cursor if possible:
let currentDir = g:NERDTreeFileNode.GetSelected()
if currentDir == {}
return
endif
let link = currentDir.path.str()
" Convert it to the format Utl expects:
let link = substitute(link, '\', '/', 'g')
let link = substitute(link, ' ', '%20', 'g')
let link = 'file://' . link
silent call Utl('openLink', link)
redraw!
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment