I started to implement multiple cursor and selection support in KDE’s famous text editor kate a while ago, but eventually didn’t quite have the time to finalize it. I am currently at Akademy in Spain, KDE’s annual developer conference, and decided that would be a good time to pick it up again and make it actually work. Here it is in action:
What does it do?
It allows you to have an arbitrary amount of cursors and selections in KTextEditor. They all mirror what you do with the primary one — text input, text removal, navigation, text selection, …
- Place any amount of cursors with mouse and keyboard shortcuts.
- Have any amount of (disconnected, i.e. non-continuous) selections. Each selection has exactly one cursor at either its start or its end, but the selection for a cursor is allowed to be empty. Selections do not need to have the same size.
- Freeze and unfreeze your secondary cursors, allowing you to move only the primary cursor, or all of them simultaneously.
- Perform most editing, text selection and text navigation features on all cursors simultaneously.
What is it good for?
How do I use it?
Usage is relatively simple; the shortcut for controlling multicursors is currently Ctrl+Meta (Meta is the key with the Windows icon on it). Press Ctrl+Meta and click in your document to place a secondary cursor. Then, just do whatever you would normally do with the keyboard. Press Esc to clear all secondary cursors.
You can place cursors with just the keyboard by pressing Ctrl+Meta+D (“toggle secondary cursor at current position”). Doing that will freeze all secondary cursors, and the keyboard now only moves the primary cursor until you unfreeze them again with Ctrl+Meta+F.
You can also create multiple and additional selections by pressing Ctrl+Meta, and then just using the mouse to select text.
What’s the state?
Most things work, there will be some issues I’m not aware of. What is at the moment completely broken is persistent selection, and the block selection mode. Both just do random things. I will need to fix that — or do you want to help? Assistance is very welcome.
If you want to test things, I’m sure you can find issues around static and dynamic word wrap, and folding.
How do I try it?
Check out the “multicursor” branch in the ktexteditor repo and build it, then start kate or any other application using the katepart editor component. Or, get a kate AppImage with multicursor support from here: http://files.svenbrauch.de/kate-linux/multicursor/
Please leave feedback in the comments if you try it out!