我是一个新的vim用户,按照这个指南,让vim自动缩进python代码并标记不必要的空白:https://realpython.com/blog/python/vim-and-python-a-match-made-in-heaven/#vim-extensions
我遇到的问题是当我在一个.py文件上启动vim时收到这个错误:Error detected while processing BufRead Auto commands for "*.py":
E28: No such highlight group name: BadWhitespace
这个错误我注释掉了以下几行:
" Flag unnecessary whitespace
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/ <- this line
" UTF8 Support
set encoding=utf-8
" Proper PEP8 Identation
au BufNewFile,BufRead *.py
\ set tabstop=4
" \ set softtabstop=4 <-- this line
\ set shiftwidth=4
\ set textwidth=79
\ set expandtab
\ set autoindent
\ set fileformat=unix
如何修复此错误?这是我完整的.vimrc文件:
^{pr2}$
有一个更简单的解决方案。你看,我也遇到了同样的问题,经过这个小把戏,没有错误消息,一切都在正常工作。在
诀窍是,BufNewFile,BufRead应该用空格隔开。 所以这条线应该看起来像
而不是
au BufNewFile,BufRead *.py
谨致问候或者从here:
命令:
如果定义了
^{pr2}$BadWhitespace
突出显示组,则将突出显示尾随的空白。要检查它是否已定义,请执行:highlight BadWhitespace
。如果未定义,则可以使用默认亮显组,例如:或者定义一个
BadWhitespace
高亮显示组。一种可能的颜色组合是:在使用
BadWhitespace
的autocmd之前添加这行代码。在相关问题 更多 >
编程相关推荐