Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Multiple Cursors #30

Closed
Jeehut opened this issue Mar 27, 2022 · 6 comments
Closed

✨ Multiple Cursors #30

Jeehut opened this issue Mar 27, 2022 · 6 comments
Labels
editor enhancement New feature or request

Comments

@Jeehut
Copy link

Jeehut commented Mar 27, 2022

Problem:
Sometimes, you have multiple variables or a collection and you want to edit all occurrences at the same time.

Solution:
Other code editors like Atom and even Xcode have added multiple-cursor support to conveniently edit multiple places at once, this can save lots of time. We should add a similar feature here, too. Part of supporting multiple cursors, it's also important that this feature is accompanied by ways to create multiple cursors. I suggest the following two ways:

  1. A shortcut that select other occurrences of the currently selected text within the same file (creating multiple cursors with selection). In Atom that's Cmd+D, in Xcode it's Cmd+Alt+E. I suggest that this comparison is case-sensitive.
  2. A keyboard-command to explicitly specify the places with the mouse cursor where the multiple text cursors should be created. In Xcode, this happens by holding the Alt key and either pressing manually into multiple places or by simply clicking the mouse and dragging it down to create multiple cursors at the same column on multiple lines.
Screen.Recording.2022-06-01.at.4.53.30.PM.mov

Alternatives considered:
Making the search with the shortcut case-insensitive (like Xcode does by default, it changes based on your last search settingS) makes this feature error prone when there's for example a class named String and 5 variables named string and I want to just edit the variables, I might accidentally also select the class.

Atom also supports a shortcut for finding all occurrences of the currently selected text in the file and create multiple cursors for all. This seems to be an extra feature that could be added later on. In the meantime, just holding the last key of the shortcut should select all entries within the same file relatively quickly as an alternative.

@Jeehut Jeehut added the enhancement New feature or request label Mar 27, 2022
@austincondiff austincondiff changed the title [FEAT] - Add support for multiple cursors [FEAT] - Multiple Cursors Mar 31, 2022
@austincondiff austincondiff changed the title [FEAT] - Multiple Cursors ✨ Multiple Cursors Mar 31, 2022
@stale stale bot added the wontfix This will not be worked on label May 30, 2022
@austincondiff austincondiff removed the wontfix This will not be worked on label Jun 1, 2022
@CodeEditApp CodeEditApp deleted a comment from stale bot Jun 1, 2022
@CodeEditApp CodeEditApp deleted a comment from Jeehut Jun 1, 2022
@austincondiff
Copy link
Collaborator

austincondiff commented Jun 1, 2022

When you hold option, any subsequent click will add additional cursors in the location that was clicked. If there is already a cursor in that location and there is more than one cursor, it removes that cursor.
If option is held and the mouse is pressed down and dragged, it makes a secondary selection.

If option + shift is held and the mouse is dragged, then it enables column selection and you can either add cursors if the mouse is moved straight down or if it is moved diagonally it will make a selection from the mouses start x position to the mouses end x position on each line from the mouses start y position to the end y position.

If the user cuts or copies while multiple items are selected, it will cut all items and when pasted, each cursor will paste the item that it cut or copied so long as their are the same number of cursors as when the text was cut/copied. If there is a different number of cursors, it will paste everything in the clipboard for each cursor.

@Wouter01
Copy link
Member

Wouter01 commented Mar 8, 2023

@austincondiff, can this be closed as it'll be added in the upcoming STTextView release?

@austincondiff
Copy link
Collaborator

@Wouter01 when the updated version is included in CodeEdit we can close this issue.

@austincondiff
Copy link
Collaborator

Closing as this is now possible with ⌃⇧. We will probably want a setting to change this shortcut though.

@github-project-automation github-project-automation bot moved this from 📋 Todo to 🏁 Complete in CodeEdit Project Jun 3, 2023
@Jeehut
Copy link
Author

Jeehut commented Jun 4, 2023

@austincondiff Thanks, sounds awesome! 🚀

But I would suggest changing the shortcut to match the Xcode shortcut which I mentioned in the initial post. That would make Xcode users feel right at home, which I think is a goal of this project.

And what about alt-clicking? Is that also possible? If not, could we create an extra feature request to track its progress?

@austincondiff
Copy link
Collaborator

austincondiff commented Jun 4, 2023

@Jeehut I just opened CodeEditApp/CodeEdit#1295 yesterday which may shed some light on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor enhancement New feature or request
Projects
Status: 🏁 Complete
Development

No branches or pull requests

3 participants