Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4039268
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:35:10+00:00 2026-05-20T12:35:10+00:00

Regarding code formatting I’m kind of purist :). I very often remove unnecessary white

  • 0

Regarding code formatting I’m kind of purist :). I very often remove unnecessary white spaces (lines with only ws, ws at the end of lines etc). I even have set vim to show that kind of lines colored to red.

My problem is that using git-diff I often see something like this:

-      else{ 
+      else{

Even if I have git-diff colored I can’t see difference (in that particular situation I removed 1 ws at the end of line). Is there any way to tell git-diff to show that ws colored to red? (for example those matched with /\s+$/ regexp).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:35:10+00:00Added an answer on May 20, 2026 at 12:35 pm

    With with Git 2.11 (Q4 2016) and after, you can do:

    git config diff.wsErrorHighlight all
    

    See doc on git diff and on git config.


    For versions older than that, you can set the color.diff.whitespace config setting, e.g. with:

    git config color.diff.whitespace "red reverse"
    

    (I’m assuming that you already have color.diff or color.ui set to auto since you say that you see coloured patches from git diff anyway.)

    If you want to fine tune the type of whitespace errors that are highlighted in red, you can then change core.whitespace, but blank-at-eol is enabled by default so you probably won’t need to change that for the example you mention.

    A possible source of confusion is that in the output of git diff, whitespace errors are only highlighted in the lines that are introduced, not those that are removed. (Update: as Paul Whittaker points out in his answer, which you should up-vote :), you can see these by reversing the sense of the diff with git diff -R.)

    You can find more documentation on these config options in the git config man page

    If you don’t want to use the -R kludge you can use the WhiteSpace Error Highlight option from the diff man page.

    –ws-error-highlight=

    Highlight whitespace errors on lines specified by in the color specified by color.diff.whitespace.
    is a comma
    separated list of old, new, context. When this option is not given,
    only whitespace errors in new lines are highlighted. E.g.
    –ws-error-highlight=new,old highlights whitespace errors on both deleted and added lines. all can be used as a short-hand for
    old,new,context.

    git diff --ws-error-highlight=new,old <file>

    or

    git diff --ws-error-highlight=all <file>

    With versions older than 2.11, there’s no way to permanently turn this on and store this in config aside from using an alias:

    git config alias.df 'diff --ws-error-highlight=all'

    Now you can use:

    git df <file>

    To see the changes in red.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with some source code regarding OpenSSL and Cpp. For some
I am trying to find the right way to write code regarding checking for
I have a question regarding the following code snippet I came across in one
Imagine I have the following code (simplified regarding my real context of course): <div
i need ur help regarding web services in classic asp here is my code
I have the following code, and i have a problem regarding changing the ringtone
I came here to ask a simple, very beginner question regarding python. I just
I am facing an issue regarding EF code first version while mapping one entity
I am trying to understand this example code regarding Browser Helper Objects. Inside, the
In JavaScript, the standard rules for code formatting don't seem to cut it. You

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.