howl icon indicating copy to clipboard operation
howl copied to clipboard

Multiple cursors

Open sheosi opened this issue 7 years ago • 15 comments

I've been lately using Howl, coming from Sublime Text/ Atom one major feature I miss is multiple cursors. They are very useful for doing the same edit on different parts.

sheosi avatar Oct 19 '16 11:10 sheosi

Is there a plan to implement this at some point? Could multiple cursor be implemented as a bundle ?

MarcusE1W avatar Aug 03 '17 19:08 MarcusE1W

I would personally like to have this, but as for when/if it will be done that depends on whether someone gets it done. No, I don't see how this could be implemented as a bundle, it would require some work down at the aullar layer where the cursor handling would need to be generalized and support for multiple cursors added. Making everything aware of multiple cursors would need some larger changes I believe.

nilnor avatar Aug 07 '17 09:08 nilnor

Maybe it can remain a feature request for now an every time a change at the aullar layer is made it could be investiated if it can be made in support of this solution?

MarcusE1W avatar Aug 16 '17 14:08 MarcusE1W

@MarcusE1W I'm curious what your main use cases for multiple cursors are?

shalabhc avatar Aug 16 '17 20:08 shalabhc

Addmittedly I mostly find it a cool feature. More practical use cases are when yuo work with structured text and want to change the structure or data typed for example. A howl specific example was the other day when I have chnged a theme bundle with the definition of colours on top, I wanted to change that a bit and every line was involved. I think it's also a nice feature when you deal with CSS, a lot off structured text there.

MarcusE1W avatar Aug 20 '17 17:08 MarcusE1W

FWIW you can usually use select text -> Ctrl-Shift-H -> Ctrl-R and a regex to do this. A little odd at first, but if you're good at regexes, you'll get used to it. In addition, you get a ton of flexibility with it, too.

refi64 avatar Aug 20 '17 18:08 refi64

You are absolutely right. Thing is I never could get around to learn the regex expressions. Maybe that's why I am attracted to multiple cursors. But definately, find and replace is a possible alternative solution. Multiple cursors just feel like a very elegant and intuitive solution in some cases. But I am absolutely happy to accept that the contributers might be more interested in other areas. Especialy as I won't be of much help to implement this due to a disctinct absence of any knowledge of Lua or Moonscript.

MarcusE1W avatar Aug 21 '17 15:08 MarcusE1W

As MarcusE1W said it's way easier, when I'm coding something I really don't feel like: well, we have to change this into this, so which regex should I use? It's not matter of knowing or not regexes (which are very useful) it's a matter of not changing your mental focus.

Also, Sublime makes use of this for some commands, enabling the use of them over differents regions of the text, e.g: you can select different parts and sort them, even if those parts are not contiguous.

I really advise anyone to try Sublime Text/Atom to see how this feature works in first hand.

sheosi avatar Aug 24 '17 06:08 sheosi

I feel for some common uses a new targeted command such as replace-word would be better. You don't need to know regexes. I haven't played around with this feature much so I'm not sure where else this might be useful.

Anyway, if we're going to implement this in the future - maybe we should consider changing the core API to have a list of cursors and selections, instead of just one. For now it will only have one item in the list but at least the code wont break if we add multiple?

shalabhc avatar Aug 24 '17 07:08 shalabhc

VSCode implementation of multiple cursor is also quite good. ctrl_d finds the next highlighted text occurrence. Quite the useful feature. Today, I tried it in howl, it doubles the highlighted text. Had higher hopes for the output.

imaia avatar Nov 09 '17 17:11 imaia

Chiming in. I am starting to hit a need for this feature too.

However, instead of modelling Sublime I want to suggest to use Java IDEA as model for this feature instead. I admit I have limited experience with Sublime, yet I dare to say that IDEA, Clion, Phpstorm and other editors in this family have one of the best multicursor support on the market.

Selection can be grown and shrunk dynamically with keyboard and toggled on and off easily. I know Sublime can somehow select words on non adjacent lines even, but that implementation was bit problematic to drive around. Also this is (multicursor) distinct problem to "word changing" (same word on multiple lines).

"Word changing" is accesible in IDEA and QtCreatror as refactoring tool, where it is, usually, function level scoped. One issues "refactor" command on word of interest, and all instances of this word can then be edited concurrently (usually with cool "live preview" which is great for additional inspection) by editing the word one is positioned on. Multicursor is however different thing - you are more interested in moving multiple cursors around consistently.

And that is what IDEA does, all word/cursor navigation commands navigate each cursor independently. You can, by issuing end-of-line command, to move all the cursors in unison, so that editing makes sense (like to add array comma, or variable name prefix/suffix).

This allows you to get column of words from say a sh command listing (using some external tool like awk) and then use multicursor to copy+paste it multiple times as multiple columns, right next to each other, while adding quotes and comma to first column items, and finally enclosing each line in array delimiters in just a few keystrokes.

This gets triple handy when editing complex structs in c, lua tables, json or php.

Actually in my case, IDEA is so good at this (for me) that I routinely have it running just be able to edit and fix C structs (and such) from QtCreator, nano, Leafpad, Texadept, and others, copying them back and forth.

My main problem with IDEA is, that it is mega heavy process, with several dozens of threads, suffering from intermittent java garbage collector pauses. It is painful to start it, just to edit few structs (but in the end, usually, it is still worth the hassle and time lost).

It would be really cool if one could offload this kind of work to howl, as it excels in everything else, especially speed and flexibility.

etosan avatar Jun 21 '18 10:06 etosan

I'd love to have it as well - I also like the way Emacs implements that.

Is there a guideline so I can implement myself ?

thiagomg avatar May 19 '20 18:05 thiagomg

I tried to look deeper into howl but it's moonscript magic is still too terse for me, I cannot parse it. If you want to work on this you will basically have to plunge deep inside and start hacking.

etosan avatar May 21 '20 12:05 etosan

I am addicted to multiple cursors. Cannot live without them. I discovered them in Sublime text, but I'm kind of getting tired of its closed source, so I'm looking around for a replacement. Howl looks interesting, but this is something I miss a ton. Here I want to add a few points.

Why multiple cursors?

It's not just a different approach to find-and-replace. It's a completely different beast.

It works with whitespace. And with newlines. I can do copy/cut & paste in multiple places. I can do many different things by remembering a single shortcut - Ctrl+D. I can do some of those things faster by remembering two other shortcuts. That's it. It's a very flexible tool and very easy to use. Interactive, with instant feedback.

Picture a thousand words? Well here you have a GIF of my solution to my friends' problem:

Peek 2019-08-26 17-46

Other examples:

  • Change variable name in your script. This one is easy to do in other ways, like find-and-replace.
  • Change all spaces to tabs. Or semicolons to comas in a CSV.
  • Rearange columns of data with cut & paste across all rows.
  • Change newlines to spaces or comas. Convert a column of sample names to a Python list or R vector with a few keystrokes.
  • Clean up messy output of some program. Some patterns are not immediatelly obvious and cannot be easily cought with find-and-replace or regexes. Sometimes it could involve a few rounds of sed. Or you could catch edge cases directly as you manipulate the file in front of your eyes, interactively, with multiple cursors.

In short - I can solve most problems before you even come up with a regex that (maybe partially) tackles them.

Other FOSS editors with multiple cursors

I'm listing these in case you would like to "borrow" some code.

  • Micro - a CLI editor with a strong Sublime-text feel. Written in Go, with plugins in Lua. The implementation of multiple cursors is not perfect as it doesn't allow working on whitespace for example.
  • Atom - a GUI editor with a strong Sublime-text feel. Electron based. The implementation of multiple cursors is good enough, although a few things are still missing. Don't like the rest of the editor too much though.

I like how Howl seemingly fits between the two. It is a GUI editor, which means I can open text files from Files, without jumping to Terminal. But it's not slow and cumbersome like Atom. It has a great potential, and multiple cursors is the kind of feature that would elevate it even further, imho.

Those are my two cents :wink:

janxkoci avatar Mar 17 '22 09:03 janxkoci

Same here. I use multiple cursors all the time. I wanted to migrate from Emacs to howl, but I'm waiting for that. I planned to implement myself, but my free time is so very short with my kids that I haven't even started

On Thu., Mar. 17, 2022, 02:43 Jeňa Kočí, @.***> wrote:

I am addicted to multiple cursors. Cannot live without them. I discovered them in Sublime text, but I'm kind of getting tired of its closed source, so I'm looking around for a replacement. Howl looks interesting, but this is something I miss a ton. Here I want to add a few points. Why multiple cursors?

It's not just a different approach to find-and-replace. It's a completely different beast. It works with whitespace. And with newlines. I can do copy/cut & paste in multiple places. I can do many different things by remembering a single shortcut - Ctrl+D. I can do some of those things faster by remembering two other shortcuts. That's it. It's a very flexible tool and very easy to use. Interactive, with instant feedback.

Picture a thousand words? Well here you have a GIF of my solution to my friends' problem:

[image: Peek 2019-08-26 17-46] https://user-images.githubusercontent.com/19331850/158779318-7f2b3627-b274-49ea-8a85-c19b21931cae.gif

Other examples:

  • Change variable name in your script. This one is easy to do in other ways, like find-and-replace.
  • Change all spaces to tabs. Or semicolons to comas in a CSV.
  • Rearange columns of data with cut & paste across all rows.
  • Change newlines to spaces or comas. Convert a column of sample names to a Python list or R vector with a few keystrokes.
  • Clean up messy output of some program. Some patterns are not immediatelly obvious and cannot be easily cought with find-and-replace or regexes. Sometimes it could involve a few rounds of sed. Or you could catch edge cases directly as you manipulate the file in front of your eyes, interactively, with multiple cursors.

In short - I can solve most problems before you even come up with a regex that (maybe partially) tackles them. Other FOSS editors with multiple cursors

  • Micro https://micro-editor.github.io/ - a CLI editor with a strong Sublime-text feel. Written in Go, with plugins in Lua. The implementation of multiple cursors is not perfect as it doesn't allow working on whitespace for example.
  • Atom https://atom.io/ - a GUI editor with a strong Sublime-text feel. Electron based. The implementation of multiple cursors is good enough, although a few things are still missing. Don't like the rest of the editor too much though.

I like how Howl seemingly fits between the two. It is a GUI editor, which means I can open text files from Files, without jumping to Terminal. But it's not slow and cumbersome like Atom. It has a great potential, and multiple cursors is the kind of feature that would elevate it even further, imho.

Those are my two cents 😉

— Reply to this email directly, view it on GitHub https://github.com/howl-editor/howl/issues/272#issuecomment-1070661396, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRMGICW3PQZGQJCVUVPMMTVAL5E5ANCNFSM4CTLNNTA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

thiagomg avatar Mar 17 '22 16:03 thiagomg