Skip to content

Conversation

benomahony
Copy link

@benomahony benomahony commented Sep 28, 2025

PR Description

Maybe I'm being dumb but I couldn't get word diff working with any of the existing options but this works!

Screenshot 2025-09-28 at 11 08 48

Unfortunately the chunk selection seems a lot more complex.

Go is not my daily driver so any pointers would be appreciated 🙇

Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

@stefanhaller
Copy link
Collaborator

Thanks; while I can understand where the need comes from, I'm not a fan of this. Maybe that's because I think there are better solutions than git's --word-diff (see here), but also because it doesn't play well with pagers, and I think using lazygit without a pager is a waste.

So we'd probably have to disable the pager when the word-diff option is on, but this would be such a shame, especially since most pagers are already better at displaying intra-line changes than git's word-diff option is (see above).

So I have to say I would be rather against adding this.

I'm currently working on supporting multiple pagers that you can cycle through; this will allow you to add a script that calls git diff --word-diff, and use that as an external diff command.

@stefanhaller
Copy link
Collaborator

The PR for multiple pagers is here, if you want to give it a try: #4953.

To switch between the regular diff without a pager and a word-diff, you'd save the following script as word-diff.sh somewhere:

#!/bin/sh

git diff --word-diff --no-index --color=always --no-ext-diff "$2" "$5"

and then use the following lazygit config:

git:
  pagers:
    - pager: ""
    - externalDiffCommand: /path/to/word-diff.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants