Question

Using vim; I'm trying to add a file (a .py file) into a directory via NERDTree. I just had to browse to the directory I want to put my file in and hit "m" and then "a" to name my file into the directory. Problem is that NERDTree keeps telling me this: "NERDTree: Node Not Created." which means that the file was not created.

Why is that? I'm I missing something?

Thanks

EDIT:

When I try to create a directory, vim (NERDTree in fact) fails and displays this error message:

Error detected while processing function <SNR>14_showMenu..30..47..NERDTreeAddNode:
line   18:
E716: Key not present in Dictionary: isOpen || !empty(parentNode.children)
E15: Invalid expression: parentNode.isOpen || !empty(parentNode.children)
Error detected while processing function <SNR>14_showMenu..30..47:
line    6:
E171: Missing :endif
Error detected while processing function <SNR>14_showMenu..30:
line   19:
E171: Missing :endif
Was it helpful?

Solution

I think there is a bug with NERD Tree.

It seems that it is linked to spaces in directory names. Try to make a directory then trace the file path back to the lowest directory with a space in it. You might find a separate directory has been created with the spaces 'escaped' with a backslash. Nodes are created under this hierarchy.

Try cloning and installing this patched version - as suggested in a comment by GWW - using git. This fixed the problem for me.

Alternatively, don't use NERDTree to create files if there are spaces in the path.

OTHER TIPS

Check to make sure you are using the latest version of NERDTree

Just look at the file ~/.vim/plugins/NERD_tree.vim and make sure the line let s:NERD_tree_version = '4.1.0' is near the top.

Also make sure the file ~/.vim/nerdtree_plugin/fs_menu.vim exists. This is required for nerdtree file commands.

This functionality works perfectly over here, so it could be something to do with your specific setup. Are you sure you have valid permissions to create a file in that directory? Or maybe it has something to do with the naming of your file.

This is a long shot, but I had a similar problem and it turned out to be because I was using symlinks to point my .vim and vimfiles directories to Dropbox... and I'd accidentally changed the target of the symlinks while mucking around with seemingly unrelated stuff.

Recreating the symlinks fixed things.

I know this is an old question but I think people still have this issue. I've been puzzled on OS X MacVim for a while! I think it is related to having spaces in the path. The key to fixing this is to update fs_menu.vim (It's in the ~/.vim/nerdtree_plugin/ folder).

To resolve this issue I got the latest version of NERD Tree from the official repository:

git clone https://github.com/scrooloose/nerdtree.git

Go into the cloned git repository named nerdtree:

cd nerdtree

Copy NERD_tree.vim to ~/.vim/plugin/

cp plugin/NERD_tree.vim ~/.vim/plugin/

Copy the nerdtree_plugin folder which contains fs_menu.vim

cp -r nerdtree_plugin ~/.vim/

In the previous command on OS X make sure you specify nerdtree_plugin not nerdtree_plugin/.

This might be a simple permission issue. It depends where you are trying to create the file. Try to execute the command directly from your editor. My vim command

:!touch somefile.py

gives the same response. Moreover when I go to the command line and try to touch somefile.py in the same location, it doesn't let me.

Things drastically change when I add sudo to the command.

However, even though you can add sudo in the vim editor like so

:!sudo touch [/path/to/]somefile.py

I don't think you can make NERDtree become root on the fly.

Therefore you need to make NERDtree a sudoer. I don't think NERDtree runs a user as it is a plugin for vim so a quick and dirty solution is to run vim in sudo mode sudo vim after this when you open up your NERDtree and type m a and then enter the file or dir/ name it will create it for you without any issue

Obviously there is a reason why vim editor is not root and you should run it as root only when you need it, as in case when you are editing sensitive files

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top