我试图在文件保存时运行标记。但是我无法在函数中获得当前缓冲区的名称,我需要在编写之后使用这个名称,因为我希望ctag处理新的修改。理想情况下我想通过。参数到autocmd的函数中。
23 function! UpdateTagsIfHasTags()
24 echom "adsfsdf"
25 return
26 let tagsPath = printf('%s/tags', expand("%:h"))
27 if !empty(glob(tagsPath))
28 system(printf('/usr/local/bin/phpctags %s', filepath))
29 endif
30 endfunction
31 augroup tags
32 autocmd!
33 autocmd BufEnter *.tex silent! !start /min ctags *.tex
34 autocmd BufEnter *.php :call UpdateTagsIfHasTags()
35 augroup END如何将当前文件路径传递给函数?
发布于 2022-02-09 02:36:50
您可以使用特殊变量<afile>或<amatch>获得自动can文件名。详见:h expand,:h <afile>,:h <amatch>。
function! Update()
echom expand('<afile>')
echom expand('<amatch>')
endfunction
autocmd BufEnter *.vim :call Update()https://stackoverflow.com/questions/71024963
复制相似问题