Moon Light Box

Less is More

Vim - How to Highlight Trailing Whitespace?

During Vim editing, We must have to delete unnecessary trailing whitespace which make code easy to read or merge.

So you can add .vimrc file in /YOUR_HOME_PATH/

1
2
$ cd
$ vim .vimrc

Add below contents then save and exit.

1
2
3
hi Whitespace ctermbg=darkred guibg=darkcyan
autocmd BufEnter * if &ft != 'help' | match Whitespace /\s\+$/ | endif
autocmd BufEnter * if &ft == 'help' | match none /\s\+$/ | endif

Enjoy it.

Reference : vim 顯示多餘空白( trailing whitespace )

Comments