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 comm开发者_JS百科ands 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()
精彩评论