开发者

Vim autocommand produces E488: Trailing characters

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()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜