Vim 自动命令产生 E488 : Trailing characters

标签 vim

我正在尝试将以下自动命令插入 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

但是vim不断告诉我以下错误消息:
Error detected while processing BufEnter Auto commands for "*.c":
E488: Trailing charcters

但是自动命令执行得很好。任何想法我做错了什么。我还在 vimrc 上使用了 dos2unix 来确保正确的行尾。

谢谢您的帮助,
安德烈亚斯

最佳答案

您不需要 :<cr>作为自动命令执行命令。

autocmd BufEnter *.c call SourceTagsVim()

关于Vim 自动命令产生 E488 : Trailing characters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5059458/

相关文章:

vim - 我可以在当前标签的左侧打开一个新标签吗?

ruby-on-rails - 在 Rails 项目中使用 vim 的 command-t

git - 无法执行编辑器

c++ - 如何以特定方式在 vim 中配置缩进?

vim - 如何在窗口右侧打开 Vim 的 Taglist 插件?

Git:通过符号链接(symbolic link)克隆需要密码?

vim - vimscript 中函数被多次调用

linux - Linux 程序员如何在不使用 IDE 的情况下创建 GUI 应用程序?

bash - 为什么 .vimrc 不被执行?

html - Vim Solarized colorscheme 无法与 html 一起正常工作