2

How could I see along my code what lines have been modified but not committed in my git repo, and what lines have been staged?

For instance the lines that have been modified but not commited could have a blue bar to their left, and the lines that have been staged could have a green bar. Or they could be highlighted in some colors.

2 Answers 2

2

It's not a built-in feature

I don't think this is a built-in feature of Kate, so you will have to use some other kind of diff tool to do what you want.

I was also interested in a better answer to your question, so I did some research. There are some workarounds to do what you want...

Relevant StackOverflow question, basically about what you want to do:
How do I show the changes which have been staged?

Use a diff tool in Kate

  • Use the built-in Terminal in Kate (Linux only)

For a similar diff GUI to Kate, you can use KDE's "Kompare" which should be in the repos of most distros.
Kompare Manual

You can start Kompare from the terminal in Kate.
cd to your local git repo, then
git diff --cached | kompare -o -

  • Use the Build Plugin (cross-platform)

There is another, more convenient workaround to start Kompare in Kate, using the Build Plugin. This also works in the Windows version of Kate which has no terminal. It also saves you from having to type the commands into the terminal every time, shortening the action to open Kompare to the click of a button.

Here is an imgur album, describing the necessary steps.

Create an extension for Kate

It may be possible to create an extension for Kate to add the ability to use it as a diff tool, although this would certainly be a lot of work.

You could start here: Kate Manual, Chapter 6: Extending Kate

Other diff tools

There are many options and opinions on diff tools for Linux and windows, as you can see from these answers: Graphical diff tools in Linux
"Diffuse" and "Meld" look pretty good.

Of course diff can also be used from the command line. There are variations like vimdiff and colordiff with additional functionality.

Or use a different text editor

You could also try out some other full-featured GUI text editor with a diff feature or better extensibility. Some good cross-platform choices are:
- VS Code (official Microsoft version)
- VS Codium (FOSS version of VS Code)
- Atom
- Geany

Extensible editors for the command line are Vim and Emacs.


Side Note

As I found out in this old Gentoo Forum thread, there used to be an "External Tools" plugin for Kate that allowed you to add custom commands to kate that could be executed with a user-defined keyboard shortcut. It worked like this (maybe it will work again some day?):

Settings->Configure Kate->External Tools
Click New
Fill in some label
For the script, enter these two lines:
cd %directory
git diff --cached | kompare -o - Executable: kompare
Save: Current Document
CMI: "name"

Too bad that the "External Tools" plugin has been discontinued...
KDE is looking for a Maintainer to reintroduce this useful feature...

4
  • Pretty extensive answer ! Thanks for the help !
    – Cedric
    Jun 5, 2019 at 13:12
  • Kate's external tools plugin is back - and heavily improved: kate-editor.org/post/2019/2019-09-21-external-tools-plugin
    – dhaumann
    Nov 15, 2020 at 17:32
  • This is a good answer for diff tools, however the original question was aimed at highlighting changes, which is answered by @dhaumann. Regarding the "external-tools-plugin" is back, you can easily configure Kompare to be executed and if you use correct parameters, you can pass paths too (kate-editor.org/post/2019/2019-09-21-external-tools-plugin) Dec 23, 2020 at 11:36
  • I used Meld (or Kompare) via right-click, as described in this answer: unix.stackexchange.com/a/670486/129648. However, after moving to the Flatpak version of Kate, this doesn't work anymore... I still have meld installed, and the menu appears, when I right-click on the tab with two documents (you need to click on the non-active document). However, I get a message: "The selected program can not be started. Maybe is not installed". I guess this has to do with the "sandboxing" of Flatpak. I have messed with some of the settings for Kate in "Flatseal", but I can't get meld back.
    – Fabio
    Dec 19, 2022 at 10:53
2

You can just turn on the line modification indicator in the Appearance > Borders config page. It's a built-in feature in Kate.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .