Re: [OT] Vim highlighting for trailing spaces



On 6/29/07, Michael Tokarev <mjt@xxxxxxxxxx> wrote:
Kyle Moffett wrote:
> On Jun 28, 2007, at 03:20:24, Dave Young wrote:
>> And for vim trailing space, there's a tip in vim.org:
>> http://www.vim.org/tips/tip.php?tip_id=878
>
> I actually prefer this (in .vimrc):
>
> " Show trailing whitespace and spaces before tabs
> hi link localWhitespaceError Error
> au Syntax * syn match localWhitespaceError /\(\zs\%#\|\s\)\+$/ display
> au Syntax * syn match localWhitespaceError / \+\ze\t/ display
>
> It always displays trailing whitespace and spaces-before tabs... except
> if your cursor is at the end of the whitespace. The updating is
> occasionally a bit laggy (EG: Put spaces on a line and then move the
> cursor off it without pressing <ENTER>), but when you hit Ctrl-L, enter,
> or edit an adjacent line then it updates.

Stolen from an old message in LKML - I don't remember who's the author:

highlight WhitespaceEOL ctermbg=red guibg=red
match WhitespaceEOL /\s\+$/

Works without any glitches here (not "laggy"). But I don't use
syntax coloring - never tried if it works with coloring or not.


That only highlights whitespace at the end of the lines. You might
want to use pattern below to also highlight "tab after space" in the
middle of the line:

:highlight RedundantSpaces ctermbg=red guibg=red
:match RedundantSpaces /\s\+$\| \+\ze\t/

--
Dmitry
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: Yet Another Spinoza Challenge
    ... whitespace between code elements have on a C program's ... Apparently, whitespace is critical. ... But it could be spaces or tabs. ... In the C language, how does one write the statement, "if i NOT equal ...
    (comp.lang.c)
  • Re: Chinese Syntax
    ... is in essence the attempt at an entirely new language, ... When I could easily write it on one line without all of that crappy whitespace ... does tabs to spaces or spaces to tabs affect the compilation of your ... does a single space or a single tab have the same ...
    (comp.lang.c)
  • Re: Chinese Syntax
    ... is in essence the attempt at an entirely new language, ... When I could easily write it on one line without all of that crappy whitespace ... does tabs to spaces or spaces to tabs affect the compilation of your ... does a single space or a single tab have the same ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Newbie Sed Question.
    ... Chris, does this code presume there can be any number of leading and/or ... My problem is that I cannot know how many leading or trailing ... only spaces and tabs are allowed for the criteria to be true. ... Would be transformed inot ...
    (comp.unix.shell)
  • Re: The "spinoza" programming language
    ... significant whitespace is pretty fragile. ... Hidden characters that look the same (space ... Source code is mostly line-oriented, so to just ignore the one thing that ... As another example Look at "make" and its whacky use of tabs. ...
    (comp.programming)