For some reason it seems the default for vim with Go files is to highlight trailing whitespace in red. In a way this is nice, but mostly I find it annoying because every time I type a space it starts as a red highlight. Is there a way to stop this behavior? I've only experienced this with Go files. Below is my vimrc, but I don't think I put anything there that would affect it.
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
From go.vim
Vim syntax file:
" 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.
Put in your .vimrc
let g:go_highlight_trailing_whitespace_error=0
There are these other options:
" - 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.
If you still like the highlighting of trailing whitespaces but not during the typing, you can try
au InsertEnter *.go match goSpaceError /\s\+\%#\@<!$/
au InsertLeave *.go match goSpaceError /\s\+$/
Read more in Highlight unwanted spaces from wikia.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With