NERDTree不能将书签写入文件(NERDTree can't write a bookmark to a file)

当我尝试在NERDTree(安装了emacs的win7)中创建书签时,

:Bookmark mybookmark

我得到这个:

E482: Can't create file C:\emacs\home/.NERDTreeBookmarks

When I try to create a bookmark in NERDTree (win7 with emacs installed)

:Bookmark mybookmark

I get this:

E482: Can't create file C:\emacs\home/.NERDTreeBookmarks

最满意答案

NERDTree默认将书签写入“$ HOME / .NERDTreeBookmarks”。 这就是代码中的样子:

call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks')

尽管可能在配置的某个位置设置了“g:NERDTreeBookmarksFile”变量,但出于某种原因,emacs更有可能将您的“HOME”环境变量设置为“C:\ emacs \ home”。 这也解释了斜杠/反斜杠混音。 你可以尝试两件事:

将$ HOME变量更改为您的主目录“C:\ Users \ your-username”。 快速谷歌出现了这个指南为Windows 7: http : //www.itechtalk.com/thread3595.html 只需将“g:NERDTreeBookmarksFile”变量设置为您的主目录(“C:\ Users \ your-username”)即可。

我推荐第二个选项,因为它肯定会起作用。 您可能需要避开反斜杠和空格,但目前我无法确定。 尝试所有这些方式,看看哪个适合你:

let g:NERDTreeBookmarksFile = "C:\Users\Your\ Username" let g:NERDTreeBookmarksFile = "C:\\Users\\Your\ Username" let g:NERDTreeBookmarksFile = 'C:\Users\Your Username'

NERDTree is trying to write the bookmark to "$HOME/.NERDTreeBookmarks" by default. This is how it looks like in the code:

call s:initVariable("g:NERDTreeBookmarksFile", expand('$HOME') . '/.NERDTreeBookmarks')

While it's possible that you've set the "g:NERDTreeBookmarksFile" variable somewhere in the configuration, it's a lot more likely that emacs has, for some reason, set your "HOME" environment variable to "C:\emacs\home". This explains the slash/backslash mixup as well. You can try two things:

Change the $HOME variable to your home dir, "C:\Users\your-username". A quick google turns up this guide for windows 7: http://www.itechtalk.com/thread3595.html Just set the "g:NERDTreeBookmarksFile" variable to your home dir ("C:\Users\your-username").

I'd recommend the second option, since it's definitely going to work. You may need to escape the backslashes and spaces, but I can't be sure how at the moment. Try it out in all of these ways and see which one works for you:

let g:NERDTreeBookmarksFile = "C:\Users\Your\ Username" let g:NERDTreeBookmarksFile = "C:\\Users\\Your\ Username" let g:NERDTreeBookmarksFile = 'C:\Users\Your Username'

更多推荐