Skip to content

Multicursor support

Waqar Ahmed requested to merge work/multicursor-new into master

This changes proposes 'basic' multicursor support for KTextEditor. Right now, it probably misses a lot of features but those can be developed overtime. What's important is that "single" cursor mode keeps working as is and to do that I made almost no change to the existing code. Multiple cursor actions run in parallel with the single cursor code, so if you never create multiple cursors, you will be running essentally the same code as before. This is kind of important I think, because implementing full scale multicursor support will take some time and if we never get it to master that time will never come. I propose an incremental approach where we have at least something that we can build upon.

Anyways, here's the list of things that work:

  • up / down / left / right / word / home / end (with selection too)
  • above movements with deletion
  • backspace / del
  • copy / cut
  • very basic insertion
  • new line with multicursors
  • auto completion with multicursors (no tail string removal yet)
  • Incremental search multi selection. We already had this via Ctrl+H. This is now modified to use multiple cursors. Everytime you hit Ctrl+H or Ctrl+Shift+H, the next occurunce of the selection will be selected with a new cursor. This is an improvement over previous version as you can now also edit / remove the "selections"
  • Kill line support for multicursors
  • text transforms (upper/lower case) with multiple cursors
  • transpose char for multiple cursors
  • commenting with multiple cursors

How to create multiple cursors?

  • Using Alt + Click
  • Using Ctrl + Alt + Up or Ctrl + Alt + Down
  • Do a selection and hit Alt + Shift + I
  • Place your cursor on a word and hit Ctrl + H, every time you invoke the shortcut it will select the next occurunce of the word under cursor.

What's missing?

  • Tests
  • Need better text insertion support, auto bracket handling and so on..
  • More of our internal actions with multicursor support (for e.g., swap lines)
  • better undo/redo support. Its usable, but can be improved so that we collapse cursors in the end or something
  • API for external apps?

What will probably never happen:

  • multicursors with overwrite mode
  • multicursors with vi mode
  • multicursors with block selection

There will be bugs with multicursor of course. But normal editing will keep working as is so I think we should try this in master and stabilize it there.

Edited by Waqar Ahmed

Merge request reports