I'm trying to insert the following autocommand into Vim:
autocmd BufEnter *.c :call SourceTagsVim()<CR>
function! SourceTagsVim()
let s:fname = expand('<afile>:p:h') . 'tags.vim'
if filereadable(s:fname)
exe 'so ' . s:fname
else
echo s:fname " could not be read"
endif
endfunction
But vim keeps telling me the following error message:
Error detected while processing BufEnter Auto commands for "*.c":
E488: Trailing charcters
But the autocommand executes fine. Any Idea what I'm doing wrong. I also used dos2unix on my vimrc to ensure the correct line endings.
Thanks for the help, Andreas
You do not need the :
or the <cr>
as autocommands execute commands.
autocmd BufEnter *.c call SourceTagsVim()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With