How to enable line numbers in Konsole

Explanation

It can be enabled as 485923 – Make line numbers discoverable in Konsole. explains:

It is undocumented (and undiscoverable), but press ctrl-alt-backslash () a couple of times.

That explains how to disable it too, but the mysterious “Sometimes” mode is explained at 485923 – Make line numbers discoverable in Konsole. as:

c-a-\ cycles between three modes - always on, always off, and a third mode which shows only when a special combination of modifiers (configurable in edit profile - advanced) is pressed.

Examples

  1. Always

  2. Sometimes

  3. Never

2 Likes

Thanks for sharing! Interesting feature.

Regarding the “Line Numbers Sometimes” mode. It was not clear to me.

In Settings | Edit Current Profile | Advanced I saw the following window:

The modifiers for URL hints seems unrelated. And what is a field “Shortcut for peeking the primary screen” is not clear to me.

But I found it is working the following way. I selected several modifiers there (Ctrl and Shift), applied changes. Then in Konsole I pressed Ctrl + Shift + \, and line numbers are shown while you hold this combination.

Also note that numbering is not aware of wrapped lines. So when you scale your text or change the window size, and some lines got (un)wrapped, the numbering will be changed. In other words, it is not like in text editor.

1 Like

@Ashark, thanks for that.

I think we’ve enough information to create some basic documentation for the feature. Are you able to create a basic wiki page for it with what you know? I’ll add what I’ve aforestated if you do. I don’t think we can really expect users to use Discourse as their primary documentation source.

The official documentation is located at docs.kde.org, and I think the appropriate page would be Chapter 7. Did You Know?, Common Issues and More. However, I doubt it would make the feature more discoverable. Unfortunately the state of the documentation tooling (docbooks) in kde is very limited, and I’d say that it would be more comfortable to read this from Discourse.

Note that currently the docs.kde.org does not support showing the latest kf6-qt6 branch for documentation.

I can suggest to also create a question-answer in the stackexchange sites.

1 Like

@Ashark,

I’ve posted Terminal emulator with line numbers? - Software Recommendations Stack Exchange, since I was banned from Stack Overflow as a child (and have never been reinstated despite a fair bit of reputation there - the Community Bot is ruthless) :<

I do somewhat agree. I’ve always been surprised that KDE hosts three independent MediaWiki instances that don’t even share preferences despite using SSO.

1 Like

There are 2 methods with this shorcut Ctrl+Alt+\ :

-1 Default Profile Built-in [Read-only]

Select settings in the konsole and open configure keyboard shortcuts. Search for toggle line numbers display (konsole) and create this shortcut: Ctrl+Alt+\
Save and exit. The shortcut has 3 options (use it inside the konsole):

-Always
-Never
-Sometimes

Line numbers are in red on the right.

-2 New Profile in Manage Profiles

Since default profile is [Read-only], you have to create a second profile (set as default) and edit as follow: Open konsole profile in advanced, go to shortcut for peeking the primary screen and create: Ctrl+Alt+\
select Line numbers: Always (optional). Save and exit. This second tweak migrates into any new profile.

All the best,

Edit: For a quicker action in the built-in profile, Toggle line numbers display is available in configure toolbars (settings).
For the new profile, the shortcut activates the 3 options, set line numbers to always in advanced (edit profile). In both cases, Ctrl+Alt+\ is always active.