如何转到 vim 中未提及扩展名的文件 (gf)?
How to go to file (gf) in vim where extension is not mentioned?
在下面的 ansible 代码中,当我将光标移动到 get_service_restart_count.yml 并在 vim 中键入 'gf' 然后它打开该文件。
- name: Delete PVC
include_role:
name: kube
tasks_from: delete_pvc
- name: get service restart count again
include: get_service_restart_count.yml
但是当我尝试对 delete_pvc
(缺少扩展名)进行相同操作时,它不会移动到文件。它抛出错误
E447: Can't find file "delete_pvc" in path
.
几乎所有 tasks_from 都没有扩展名。
vim 中是否有任何选项可以移动到缺少扩展名的文件名?
当您对没有扩展名的文件名执行 gf
时,Vim 会尝试 :help 'suffixesadd'
中的每个后缀。
在~/.vim/after/ftplugin/yaml.vim
(Unix派生)或%userprofile%\vimfiles\after\ftplugin\yaml.vim
(Windows)中,添加这一行:
setlocal suffixesadd+=.yml
(IMO 应该在默认的 ftplugin 中。)
在下面的 ansible 代码中,当我将光标移动到 get_service_restart_count.yml 并在 vim 中键入 'gf' 然后它打开该文件。
- name: Delete PVC
include_role:
name: kube
tasks_from: delete_pvc
- name: get service restart count again
include: get_service_restart_count.yml
但是当我尝试对 delete_pvc
(缺少扩展名)进行相同操作时,它不会移动到文件。它抛出错误
E447: Can't find file "delete_pvc" in path
.
几乎所有 tasks_from 都没有扩展名。
vim 中是否有任何选项可以移动到缺少扩展名的文件名?
当您对没有扩展名的文件名执行 gf
时,Vim 会尝试 :help 'suffixesadd'
中的每个后缀。
在~/.vim/after/ftplugin/yaml.vim
(Unix派生)或%userprofile%\vimfiles\after\ftplugin\yaml.vim
(Windows)中,添加这一行:
setlocal suffixesadd+=.yml
(IMO 应该在默认的 ftplugin 中。)