vim 和 NERD 树扩展 - 添加文件
当使用带有 NERDTree 插件的 vim 编辑器浏览项目树时,是否有一种简单的方法可以在当前突出显示的目录下创建新的源代码文件?
目前,我进入 shell,添加文件,然后刷新树。一定有更好的方法。
When using the vim editor with the NERDTree plugin to navigate through the tree of your project, is there an easy way to create a new source code file under the currently highlighted directory?
Currently I go into my shell, add the file and then refresh the tree. There must be a better way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
激活 NERDTree 并导航到新文件应所在的目录。然后按m调出NERDTree文件系统菜单并选择a作为“添加子节点”。然后只需输入文件(或目录的名称)即可完成。
Activate the NERDTree and navigate to the directory in which the new file should live. Then press m to bring up the NERDTree Filesystem Menu and choose a for "add child node". Then simply enter the file's (or directory's name) and you're done.
您可以从 vim 运行 shell 命令。所以在这种情况下我使用:
然后点击 r 重新加载 nerdtree 窗口。
要做的另一件事是从 vim 中启动新文件。
一件方便的事情是,在我的 .vimrc 中,我自动将 cwd 更改为当前文件所在的目录:
这样,如果我正在编辑一个文件并希望在同一位置添加另一个文件,则路径会立即更改。从 NERDTree 打开任何文件都会将目录设置为该文件所在的目录。
From vim you can run shell commands. So in this case I use:
and then hit r to reload the nerdtree window.
The other thing to do is to just start the new file from within vim.
One handy thing for this is that in my .vimrc I auto change the cwd to the directory my current file is in:
This way if I'm editing a file and want another one in the same place the path is changed right there. Opening any file from NERDTree sets the directory to the one that file is in.