NERDTree:节点未创建

发布于 2024-09-29 13:12:01 字数 723 浏览 5 评论 0原文

使用 vim;我正在尝试通过 NERDTree 将文件(.py 文件)添加到目录中。我只需浏览到我想要放入文件的目录,然后点击“m”,然后点击“a”将我的文件命名到该目录中。问题是 NERDTree 不断告诉我:“NERDTree:节点未创建。”这意味着该文件尚未创建。

这是为什么?我是不是错过了什么?

谢谢

编辑:

当我尝试创建目录时,vim(实际上是 NERDTree)失败并显示以下错误消息:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

琉璃繁缕 2024-10-06 13:12:01

我认为 NERD Tree 有一个错误。

它似乎与目录名称中的空格相关联。尝试创建一个目录,然后跟踪文件路径回到其中有空格的最低目录。您可能会发现已创建一个单独的目录,其中空格用反斜杠“转义”。节点是在此层次结构下创建的。

尝试使用 git 克隆并安装此修补版本 - 正如 GWW 评论中所建议的那样。这解决了我的问题。

或者,如果路径中有空格,请勿使用 NERDTree 创建文件。

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.

有木有妳兜一样 2024-10-06 13:12:01

检查以确保您使用的是最新版本的 NERDTree

只需查看文件 ~/.vim/plugins/NERD_tree.vim 并确保行 let s:NERD_tree_version = '4.1. 0' 位于顶部附近。

还要确保文件 ~/.vim/nerdtree_plugin/fs_menu.vim 存在。这是 nerdtree 文件命令所必需的。

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.

薄凉少年不暖心 2024-10-06 13:12:01

此功能在这里完美运行,因此可能与您的特定设置有关。您确定您具有在该目录中创建文件的有效权限吗?或者可能与文件的命名有关。

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.

半寸时光 2024-10-06 13:12:01

这是一个不太可能的事情,但我也遇到了类似的问题,结果是因为我使用符号链接将我的 .vim 和 vimfiles 目录指向 Dropbox...并且我在闲逛时不小心更改了符号链接的目标与看似无关的东西。

重新创建符号链接修复了问题。

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.

墨小墨 2024-10-06 13:12:01

我知道这是一个老问题,但我认为人们仍然有这个问题。我对 OS X MacVim 感到困惑有一段时间了!我认为这与路径中的空格有关。解决这个问题的关键是更新 fs_menu.vim (它位于 ~/.vim/nerdtree_plugin/ 文件夹中)。

为了解决这个问题,我从官方存储库获取了最新版本的NERD Tree:

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

进入克隆的名为 nerdtree 的 git 存储库:

cd nerdtree

将 NERD_tree.vim 复制到 ~/.vim/plugin/

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

复制包含 fs_menu.vim 的 nerdtree_plugin 文件夹

cp -r nerdtree_plugin ~/.vim/

在 OS X 上的上一个命令中,确保您指定的是 nerdtree_plugin 而不是 nerdtree_plugin/

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/.

定格我的天空 2024-10-06 13:12:01

这可能是一个简单的权限问题。这取决于您尝试在何处创建文件。尝试直接从编辑器执行该命令。我的 vim 命令

:!touch somefile.py

给出了相同的响应。此外,当我进入命令行并尝试在同一位置触摸 somefile.py 时,它不允许我这样做。

当我将 sudo 添加到命令中时,事情发生了巨大的变化。

然而,即使你可以像这样在 vim 编辑器中添加 sudo,

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

我也不认为你可以让 NERDtree 立即成为 root。

因此,您需要使 NERDtree 成为 sudoer。我不认为 N​​ERDtree 运行用户,因为它是 vim 的插件,所以一个快速而肮脏的解决方案是在 sudo 模式下运行 vim
sudo vim
之后,当你打开 NERDtree 并输入 m a 然后输入文件或目录/名称时,它会为你创建它,没有任何问题

显然,vim 编辑器不是 root 是有原因的,你应该仅在需要时以 root 身份运行它,例如在编辑敏感文件时

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文