gf
doesn't work for absolute links used in Azure DevOps yaml files, p.e.
- template: /devops/template/my-template.yml
(It only works without the leading slash.)
This is why I have created my custom function that tries first a gf
and then tries guessing the file that is meant:
function! GoToFile()
try
normal gf
catch
let path = expand("<cfile>")
if path[0] == '/'
...
endif
endtry
endfunction
I have mapped it to gF
:
nnoremap gF :call GoToFile()<CR>
This is just a workaround. Actually, I would like to map it directly to gf
:
nnoremap gf :call GoToFile()<CR>
But then strange things happen (after using gf
):
- No syntax highlighting for the opened file.
- Other open buffers disappear from my "buffer tabs" (no real tabs, I use ap/vim-buftabline)
- The file name in the remaining "buffer tab" looks different now (
d/t/template.yml
instead of justtemplate.yml
)
Is something wrong with this approach? Do I end up in a loop? Shouldn't nnoremap
prevent this? Is there a way to call the "original" gf
(like \ls
in bash to ignore aliases)?
command
in bash) came up a couple of days ago. Unfortunately, I can't find the question. The answer was that vim has no such feature. Hopefully, someone can post the link.