Skip to content

Instantly share code, notes, and snippets.

@scrooloose
Last active March 5, 2016 18:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scrooloose/5eedbf80a4c62d01d25c to your computer and use it in GitHub Desktop.
Save scrooloose/5eedbf80a4c62d01d25c to your computer and use it in GitHub Desktop.
nerdtree plugin to open a visual selection of files
if exists("g:loaded_nerdtree_open_multiple")
finish
endif
let g:loaded_nerdtree_open_multiple=1
vnoremap <buffer> o :call <SID>OpenMultiple()<cr>
function! s:OpenMultiple() range
let curLine = a:firstline
while curLine <= a:lastline
call cursor(curLine, 1)
let node = g:NERDTreeFileNode.GetSelected()
if !empty(node) && !node.path.isDirectory
if curLine == a:firstline
"open the first one in the previous window
call node.open({'where': 'p', 'stay': 1})
else
call node.open({'where': 'h', 'stay': 1})
endif
endif
let curLine += 1
endwhile
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment