我正在尝试让 :A
(例如在 Controller 和规范之间切换)在 vim-rails 中工作。如果我导航到我的 Rails 项目,运行 vim .
,打开 Controller 文件并运行 :A
,我收到错误:
E345: Can't find file "app/controllers/widgets_controller.rb" in path
如果我明确设置路径:
:set path=/Users/me/Documents/Code/my-project
然后 :A
按预期工作。使用 Vim 打开目录时如何设置初始路径?
最佳答案
不完全是在打开目录时:因为您似乎正在处理项目,所以给出 project plugin尝试一下。
使用它,您可以在进入或离开项目时执行任意命令。
来自插件描述:
You can use this plugin's basic functionality to set up a list of frequently-accessed files for easy navigation. The list of files will be displayed in a window on the left side of the Vim window, and you can press or double-click on filenames in the list to open the files. This is similar to how some IDEs I've used work. I find this easier to use than having to navigate a directory hierarchy with the file-explorer. It also obviates the need for a buffer explorer because you have your list of files on the left of the Vim Window.
关于ruby-on-rails - 从目录打开Vim时如何自动返回 'set path'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11732876/