cha*_*des 7 vim go vim-syntax-highlighting
出于某种原因,似乎带有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
Run Code Online (Sandbox Code Playgroud)
从go.vim
Vim语法文件:
Run Code Online (Sandbox Code Playgroud)" 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
Run Code Online (Sandbox Code Playgroud)
还有以下其他选择:
Run Code Online (Sandbox Code Playgroud)" - 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\+$/
Run Code Online (Sandbox Code Playgroud)