Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim autocommand produces E488: Trailing characters

Tags:

vim

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

like image 386
Kungi Avatar asked Feb 20 '11 19:02

Kungi


1 Answers

You do not need the : or the <cr> as autocommands execute commands.

autocmd BufEnter *.c call SourceTagsVim()
like image 186
Peter Rincker Avatar answered Oct 15 '22 04:10

Peter Rincker