开发者

Vim autocommand produces E488: Trailing characters

开发者 https://www.devze.com 2023-02-12 00:41 出处:网络
I\'m trying to insert the following autocommand into Vim: autocmd BufEnter *.c :call SourceTagsVim()<CR>

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

精彩评论

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