Go to character in Kate

I like that the position indicator in the status bar of Kate shows line:character, but when I hit Ctrl+G to go to a specific position in the text, it only allows me to enter a line number. Everythign I enter after a colon into there simply gets ignored.
In normal scripts that’s not a big deal, since each line does one thing and one thing only, meaning when I get a code position in a debugger I can find it easily enough in Kate. But when I e.g. try to take apart obfuscated scripts or scripts with terribly long lines (which do appear in some of my older scripts), I sometimes find it hard to find the specific place an issue occurred.

I’d like to know whether there is a built-in way to Kate to jump to a line:character position, or if there isn’t suggest it as an addition to the current Ctrl+G interface.

1 Like

It would make sense to enhance that to allow arbitrary xx:yy inputs, too.

Please file a bug or provide a patch :slight_smile:

Since I have nothing on Fridays and next week is höstlov here, I will try to take a look at the code and provide a patch. If I fail at doing that I’ll open a bug report to request that someone who knows their way around the codebase adds it.

1 Like

Thanks, if there are any issues, just ping me here!

@Christoph_Cullmann I have a little bit of trouble finding the implementation of that Ctrl+G interface, I only found the function to actually make the text cursor move (in usr/include/KF6/KTextEditor/ktexteditor/view.h: setCursorPosition). The closest I’ve come to find the interface was searching for every occurrence of setCursorPosition with the project search, which led me to the SearchPlugin.cpp.
And I think the fact that I have no C++ GUI programming experience and never worked with any KDE codebase either probably doesn’t help.

Ctrl+G is handled in KateGotoBar class in katedialogs.cpp file

Another slightly incovenient way to do this atm (will improve this):

  1. Open quick open Ctrl+Alt+O
  2. Enter line column like :line:column for e.g., :10:5 (notice the colon at the start)
  3. Make sure to select the file
  4. Hit enter

Step 3 is a bit incovenient

1 Like

That file being in frameworks instead of in kate itself was a little bit confusing. But thanks to you also specifying the class name I could still find it in the KF6 identifier tool and notice that I also needed to download frameworks to even look at the code locally. But I have no clue why that folder didn’t seem to be anywhere in my tree (find . -name katedialogs.cpp turned up empty), despite the fact that I have built Kate, which relies on that.
Or I am just too incompetent to navigate KDE’s codebase and should maybe let people who know their way around do it. Which I’ll likely do, as I’ll have school again next week and thus probably not the time to work on Kate. Until Sunday at least I’ll try to get it implemented myself though.

have built Kate, which relies on that

Kate can be built using precompiled libraries on your system. Probably you are building Kate directly instead of using kde-builder or kdesrcbuild.

I used kdesrc-build kate, with some flag I can’t remember rn to pull in dependencies.

Maybe you didn’t include dependencies. Try kdesrc-build --include-dependencies kate

I looked through my logs, that was the flag I used.

I now filed a bug report with “wishlist” priority: https://bugs.kde.org/show_bug.cgi?id=511795