Skip to content

Instantly share code, notes, and snippets.

@masaakif
Created February 17, 2018 16:11
Show Gist options
  • Save masaakif/90a6f842dc1d12a9b0bd03367a80774c to your computer and use it in GitHub Desktop.
Save masaakif/90a6f842dc1d12a9b0bd03367a80774c to your computer and use it in GitHub Desktop.
nerdtree menu plugin to open dir/file by windows file association. : Based from http://gist.github.com/205807
"shove this in ~/.vim/nerdtree_plugin/grep_menuitem.vim
"
" This is nerdtree menu item plugin.
" Add 'o' menu items to open selected dir/file.
" 'o' : (Windows only) open directory/file by file extension association in Windows.
" if directory is selected, open by explorer.
"
" Originally written by scrooloose
" (http://gist.github.com/205807)
if exists("g:loaded_nerdtree_open_by_win_menuitem")
finish
endif
let g:loaded_nerdtree_open_by_win_menuitem = 1
call NERDTreeAddMenuItem({
\ 'text': '(o)pen the current node with windows association',
\ 'shortcut': 'o'
\ , 'callback': 'NERDTreeExecuteFileWin32'})
" FUNCTION: NERDTreeExecuteFileWin32() {{{1
function! NERDTreeExecuteFileWin32()
let treenode = g:NERDTreeFileNode.GetSelected()
if treenode != {}
let winpath = treenode.path.str()
" for cygwin user
" let winpath = system("cygpath -w '" . treenode.path.str() . "'")
call system("explorer '" . winpath . "'")
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment