Nerdtree: [Feature Request] Open multiple files at once

Created on 31 Jan 2011  路  52Comments  路  Source: preservim/nerdtree

I'd love to being able to open multiple files at once. This would work like this:
Use Visual Line Mode (Shift+V) to select the files you want to open
Press a key combination
All files selected are opened in background buffers

feature request

Most helpful comment

+1

I would love to see NERDTree commands working on visual mode, such as open a file, delete and move.

All 52 comments

I'd like this as well, to be able like I do with the MRU plugin for example.

+1

+2

+1

I would love to see NERDTree commands working on visual mode, such as open a file, delete and move.

+1

+1 Woudl be great to open a folder in tabs

+1

Any progress 5 months later? This would be a nice thing to have.

+1 for this feature and for opening all selected files in different tabs

+1

+1

Hey, @scrooloose:

Is this Something you'd be interested in Implementing? If not, is it something you'd be up for investigating a Pull Request creating?

+1

+1

+1

:+1:

:+1:

+1

Was hoping I'd find a post on stackoverflow explaining me how to do this instead of finding a feature request on github when googling this!

+1

:+1:

+1

+1 PLEEEEEZE

This is something I'd like to see as well. In the mean time, I'll continue to use a macro.

Chuck this in your ~/.vim/nerdtree_plugin/ dir (or ~/.vim/bundle/nerdtree_open_multiple/nerdtree_plugin depending on your preferred setup)

https://gist.github.com/scrooloose/5eedbf80a4c62d01d25c

It's not the most fully featured solution, but it does the job. Just select a few files in visual mode and hit o.

Thoughts?

Hmmm.... actually, chuck the code into your ~/.vim/ftplugin/nerdtree/ directory instead.

My previous instructions would have the o mapping overridden for _all_ buffers... not just nerdtree buffers. I have updated the gist accordingly.

Same need here.

:horse: yes please

+1

+1

@scrooloose I tried a few different places to put the file, even pasting it at the bottom of fs_menu.vim, it only lets me use o like it was before.

I'll keep at it, but I wanted to thank you for putting the gist up, even if I am a year late.

I'm away from the computer till Monday night. Currently typing this on my phone (it hurts). Is the code working for you if you change the mapping to something other than 'o'? If so then I guess nerd tree is loading it's own mappings _after_ setting the file type

Nerd Tree tabs?

+1

+1

+1

+1 would like this feature as well. Tried putting gist above into:
C:\Users\User\vimfiles\plugged\nerdtree\nerdtree_plugin
in gvim, restarting etc, didn't work for me, the 'o' mapping just toggled back and forth from beg to end cursor position, its default.

This might be useful too. Instead of using visual mode to select and open from the tree list view how about using the current directory of nerdtree to pass along the name to the args list and then tab all:

args c:\dir*
tab all

That should open all files in the directory. It sort of works for me but then the tab bar runs out of room and gvim gives e36 'no more room' and the remaining buffers get put into a single split window. Not so useful.

+1
Didnt try the proposed solution. Will give feedback if I ever get to it. Thanks for the awesome plugin!

+1

+1

+1

+1

The problem with the gist above is that it executes while in the [No Name] buffer, so the mapping is not available where it's needed. Removing <buffer> (which is not the solution) reveals other error messages that may be a result of the age of the code vs. the current version of NERDTree.

+1

I've updated the gist to work with the current version of NERDTree. You can find it here: https://gist.github.com/PhilRunninger/99f0c78e48de42bf2010f30d983ff61f. Just place this file in your ~/.vim/nerdtree_plugin folder, and you'll be good to go. I'd like to get some feedback on this, and then we can decide whether (and how) to include it in the base NERDTree code.

Thanks!

I'm going to close this issue, since the gist is available as a NERDTree plugin.

Thanks for this!
I found I need to put the gist in my plugins directory's nerdtree/nerdtree_plugin/ which already existed.
By all means I think such a functionality should be incorporated to the base code with more options (like open in multiple tabs).

@elig0n , If you put it there, it may be deleted when you up date NERDTree or will interfere with the update. Instead, try putting it in the ~/.vim/nerdtree_plugin folder, which you probably will need to create.

@elig0n, @jimafisk, I don't know if you get @-mention notifications directly from the gist, so I'm tagging you here. I've fixed the issue that required you to put the gist in ~/.vim/bundle/nerdtree/nerdtree_plugin/. See https://gist.github.com/PhilRunninger/99f0c78e48de42bf2010f30d983ff61f#gistcomment-2890723.

For folks who are interested in opening in multiple tabs instead of splits, in @PhilRunninger's gist above just change the h to a t on line 16:

call node.open({'where':'t', 'stay':1, 'keepopen':1})

I've updated my gist to include mappings for opening into split or separate tabs. Its location has changed to ~/.vim/ftplugin/nerdtree.vim.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sunnyguan picture sunnyguan  路  4Comments

MuhammadMouradG picture MuhammadMouradG  路  6Comments

kevinSuttle picture kevinSuttle  路  4Comments

kristijanhusak picture kristijanhusak  路  3Comments

hrqmonteiro picture hrqmonteiro  路  3Comments