Introduction
In the world of Linux development and system administration, having tools that allow visualizing differences between files is essential for maintaining code quality and detecting unwanted changes. Kompare, part of the KDE ecosystem, offers a powerful and easy-to-use graphical interface for comparing both individual files and entire directories.
What is Kompare?
Kompare is a visual comparison application that shows side‑by‑side the content of two files or two directory trees, highlighting the lines that differ using colors and intuitive symbols. Originally designed for the KDE desktop environment, it works perfectly on any Linux distribution that has the Qt and KDE Frameworks libraries installed.
Main Features
- Text file comparison with inline highlighting of differences.
- Directory comparison, showing added, deleted, or modified files.
- Support for popular file formats such as C++, Python, HTML, XML, and many more.
- Integration with version control systems like Git, Subversion, and Mercurial via plugins or external calls.
- Ability to edit files directly from the interface and save changes.
- Horizontal and vertical split views, as well as full‑screen mode.
- Search and filtering of differences to quickly locate specific changes.
Installation on Different Distributions
Although Kompare is part of the kdesdk package in many distributions, its installation may vary slightly depending on the package manager.
- Ubuntu / Debian:
sudo apt update && sudo apt install kompare - Fedora:
sudo dnf install kompare - Arch Linux:
sudo pacman -S kompare - openSUSE:
sudo zypper install kompare
If you prefer to compile from source, the official KDE repository provides the source files and build instructions via CMake.
Basic Usage
Once installed, launch Kompare from the application menu or by running kompare in a terminal to open the main window. From there you can:
- Select File → Open to choose the two files you want to compare.
- Or drag and drop the files directly onto the interface.
- The tool will display a split view where identical lines appear in white, while differences are highlighted in red (deletions) and green (additions).
- Use the toolbar to navigate between changes, apply patches, or save a modified version.
To compare directories, choose File → Compare Directories and select the folders; Kompare will list all files and show their status (identical, different, only left, only right).
Integration with Version Control Systems
Kompare can be configured as an external diff tool for Git, Subversion, and Mercurial. For example, in Git you can set it up like this:
git config --global diff.tool kompare git config --global difftool.kompare.path kompare
Then, running git difftool will launch Kompare for each file with differences, allowing a comfortable visual review before committing changes.
Advanced Tips
- Use the filter mode to show only lines containing a specific