How to go to file (gf) in vim where extension is not mentioned?

Viewed 353

In the below ansible code, when i move my cursor to get_service_restart_count.yml and type 'gf' in vim then it open that file .

- name: Delete PVC
  include_role:
    name: kube
    tasks_from: delete_pvc

- name: get service restart count again
  include: get_service_restart_count.yml

But when i try the same with delete_pvc (where extension is missing) it is not moving to file. it throws error

E447: Can't find file "delete_pvc" in path

.

almost all of the tasks_from will not have extension in it.

Is there any option in vim to move to the file name where extension is missing?

1 Answers

When you do gf on a filename without extension, Vim tries every suffix in :help 'suffixesadd'.

In ~/.vim/after/ftplugin/yaml.vim (Unix derivatives) or %userprofile%\vimfiles\after\ftplugin\yaml.vim (Windows), add this line:

setlocal suffixesadd+=.yml

(Which should be in the default ftplugin, IMO.)

Related