出于某种原因,带有 Go 文件的 vim 似乎默认以红色突出显示尾随空格。在某种程度上,这很好,但大多数时候我觉得它很烦人,因为每次我输入一个空格时,它都会以红色突出显示开始。有没有办法阻止这种行为?我只在 Go 文件中遇到过这种情况。下面是我的 vimrc,但我认为我没有放任何会影响它的东西。
set nocompatible
syntax on
set autoindent
set tabstop=4 softtabstop=0
autocmd FileType go set tabstop=8 softtabstop=0
set formatoptions=tcroql
set relativenumber
set incsearch
set hlsearch
set smartindent
filetype indent on
最佳答案
来自 go.vim
Vim 语法文件:
" There are some options for customizing the highlighting; the recommended " settings are the default values, but you can write: " let OPTION_NAME = 0 " in your ~/.vimrc file to disable particular options.
放入你的.vimrc
let g:go_highlight_trailing_whitespace_error=0
还有这些其他选项:
" - g:go_highlight_array_whitespace_error " Highlights white space after "[]". " - g:go_highlight_chan_whitespace_error " Highlights white space around the communications operator that don't " follow the standard style. " - g:go_highlight_extra_types " Highlights commonly used library types (io.Reader, etc.). " - g:go_highlight_space_tab_error " Highlights instances of tabs following spaces.
如果您仍然喜欢尾随空格的突出显示,但在输入过程中不喜欢,您可以尝试
au InsertEnter *.go match goSpaceError /\s\+\%#\@<!$/
au InsertLeave *.go match goSpaceError /\s\+$/
阅读更多 Highlight unwanted spaces来自 wikia .
关于vim - 停止在 Vim 中高亮显示 Go 文件的尾随空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40945136/