PreviousNextTracker indexSee it online !

(194/212) 499 - Multiple caret editing

jEdit has multiple selection, but doesn't have multiple caret editing, e.g., https://www.youtube.com/watch?v=xnKN0T_UBgU. Is it possible to add that feature? Thanks.

Submitted ahlearn - 2015-08-08 18:33:19.441000 Assigned
Priority 5 Labels
Status open Group none
Resolution None

Comments

2017-10-28 23:34:28.917000
ngc

Does this macro help a bit?

if (! textArea.isMultipleSelectionEnabled() ) {
textArea.toggleMultipleSelectionEnabled();
}
os=textArea.getSelection();
textArea.selectNone();
textArea.userInput(' ');
textArea.setSelection(new Selection.Range( textArea.getCaretPosition()-1, textArea.getCaretPosition() ) );
textArea.addToSelection(os);

How to use it:
1. Position the cursor where you want your first caret
2. Execute the macro -> A space will be inserted and selected
3. If you want more carets, Place your cursor where you want your next caret and repeat from 2
4. Otherwiise start typing

This doesn't give you automatic End-Of-Line multiple-carets, but at least you have something.

2017-10-29 00:21:52.270000
ngc

And here is a macro which will select all your end-of-lines for the current selection(s)

sl= textArea.getSelectedLines();
textArea.selectNone();
for (var i=sl.length; i-->0; ) {
textArea.moveCaretPosition(textArea.getLineEndOffset(sl[i])-1);
textArea.userInput(' ');
}
if (! textArea.isMultipleSelectionEnabled() ) {
textArea.toggleMultipleSelectionEnabled();
}
for (var i=sl.length; i-->0; ) {
s= textArea.getLineEndOffset(sl[i]);
textArea.addToSelection(new Selection.Range(s-2,s-1));
}

So now you have something like the "multi-Caret-Editing".

Proposal: Close Ticket.

2017-10-30 14:21:42.499000
ahlearn

But MultipleSelection cannot edit / delete text outside of the selection..

2017-10-30 14:28:00.808000
ngc

You didn't try, did you?

Sorry! I think i understood what you meant: If I place the cursors (selections) at the end of the lines, I can only insert new characters and not even delete them. Also I cannot delete to the left.

2017-10-30 14:38:22.231000
ngc

https://youtu.be/XDuho3-nt4c

2017-10-30 22:15:09.502000
ezust

Wow, that's pretty cool! Perhaps we should add those macros to jEdit, although perhaps it needs some work still?

2017-10-31 10:04:23.131000
ngc


Feel free to add them. I do not see how I could enhance them. I'm not doing anything fancy.

The first macro simply inserts a space and selects it while keeping all the other selections.

The second one just inserts a space at the end of every selected line, dops the previous selection and selects all those spaces.

The only improvement I could think of lies within jEdit: You could allow to delete to the left of selections.

You see: In the movie, before I inserted th li-tags I pressed backspace to delete the numbers to the left of the selections. It didn't work.

Would I have used a rectangular, non-empty selection left of the numbers, I could have deleted them with backspace.

If you can make such deletions possible in jEdit, I think we have all we'd require for "multi-caret editing".

But I don't think I'm capable of changing jEdit accordingly.

P.S.: I think I broke sourceforge a bit by using less-than li greater-than ;) I deleted the post, but parts still show up here. Sorry :(