为什么vim将E488:tralling字符返回到我的函数?
我试图在保存python文件时执行一个yapf命令来格式化它,因此我创建了一个函数来调用此命令:为什么vim将E488:tralling字符返回到我的函数?,vim,neovim,Vim,Neovim,我试图在保存python文件时执行一个yapf命令来格式化它,因此我创建了一个函数来调用此命令: function Format_python_file() silent :!yapf --style="{based_on_style: pep8, indent_width: 4}" -i % silent :e % endfunction autocmd BufWritePost *.py call Format_python_file() <afi
function Format_python_file()
silent :!yapf --style="{based_on_style: pep8, indent_width: 4}" -i %
silent :e %
endfunction
autocmd BufWritePost *.py call Format_python_file() <afile>
函数格式\u python\u文件()
沉默:!yapf--style=“{based_on_style:pep8,indent_width:4}”-i%
沉默:e%
端功能
autocmd BufWritePost*.py调用格式_python_文件()
问题在于您的autocmd
行有尾随
事实上,我看到的信息非常明确:
Error detected while processing BufWritePost Autocommands for "*.py":
E488: Trailing characters: <afile>
显然,您可以找出函数中的哪一行导致了此命令。你试过了吗?我想这是第一行,运行yapf命令,但我不知道如何修复。它可以工作,但是如果我保存文件并使用:x或ZZ退出vim,为什么它不工作?如果在yapf命令中使用
,它可以工作吗?如:silent:!yapf--style=“{based_on_style:pep8,indent_width:4}”-i
augroup python_yapf
autocmd!
autocmd BufWritePost *.py call Format_python_file()
augroup END