Highlight Whitespace at End-of-Line in Vim

Usually trailing whitespace is undesirable. Using vim’s :match command you can easily highlight those trailing whitespace:

:match Error /\s\+$/

This can be combined with autocmd and inserted to ~/.vimrc to highlight trailing whitespace only for certain files:

autocmd Filetype python match Error /\s\+$/

2 thoughts on “Highlight Whitespace at End-of-Line in Vim”

  1. Hey Guy!!
    Thanks for the great tip. What is the way to “undo” the command, so that highlighting of such cases is stopped that doesn’t involve resetting vim?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.