sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
814 stars 40 forks source link

Two Cursors At the Same Time #5989

Closed danallendotcom closed 1 year ago

danallendotcom commented 1 year ago

Description of the bug

I imagine this might be a productivity booster, but I suspect this might be a bug. Please accept my apology if this is the wrong place to post this behavior of Sublime.

I made a video of the two cursors in action. I tried to attached the video file. I could not get the file to upload. I loaded to a website I control. This link will bring up the video and show the problem (link).

Basically, at times, Sublime runs two cursors in the editor window. I can't think of a good way to use this feature. I think it might be a bug. It happens randomly, a few times per day.

To clear the error, click somewhere on the screen after the click when it happens.

Steps to reproduce

The problem occurs randomly, when clicking on the appliication window after having been working in another one. Happens 3-6 times per day.

Expected behavior

One cursor in editor instead of two.

Actual behavior

Two cursors active in editor at the same time.

Sublime Text build number

4143

Operating system & version

Windows 10

(Linux) Desktop environment and/or window manager

n/a

Additional information

No response

OpenGL context information

No response

BenjaminSchaaf commented 1 year ago

Multi-cursor is one of the defining features of Sublime Text and featured on the front page of https://sublimetext.com. It's extremely useful for making the same change in multiple places at once.

themilkman commented 1 year ago

It is as @BenjaminSchaaf said. If this interrupts your workflows anyway, you could try to disable the key and mouse binding for it. For example, this is the default in the keybinding:

{ "keys": ["alt+shift+up"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["alt+shift+down"], "command": "select_lines", "args": {"forward": true} },

You could override it by adding this:

{ "keys": ["alt+shift+up"], "command": "noop"},
{ "keys": ["alt+shift+down"], "command": "noop"},

There is also a sublime-mousemap file with:

  {
    "button": "button1", "count": 1, "modifiers": ["ctrl"],
    "press_command": "drag_select",
    "press_args": {"additive": true}
  },

which you could override with:

  {
    "button": "button1", "count": 1, "modifiers": ["ctrl"],
    "press_command": "drag_select",
    "press_args": {"additive": false}
  },

That being said, having and using multi-cursor support is a mighty and extremely useful feature. It's worth to get used to it for everyday work.

danallendotcom commented 1 year ago

Thank you for responding.

Multi cursor, wow. Have programmers given up the notorious habit of avoiding anything that repeats? I am known for lacking intelligence, this must be another case where that hinders me. I cannot think of any cases where multiple cursors would be helpful;. I looked for something about multi cursors at the link you provided, but the word cursor is not on the page. I am very curious to see an example where the multi-cursor is helpful.

I could not overriede { "keys": ["alt+shift+up"], "command": "select_lines", "args": {"forward": false} }, { "keys": ["alt+shift+down"], "command": "select_lines", "args": {"forward": true} },

because that is not in my key bindings but I found

{ "keys": ["ctrl+alt+up"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["ctrl+alt+down"], "command": "select_lines", "args": {"forward": true} },

and tried overriding with { "keys": ["ctrl+shift+up"], "command": "noop"}, { "keys": ["ctrl+shift+down"], "command": "noop"},

BenjaminSchaaf commented 1 year ago

I looked for something about multi cursors at the link you provided, but the word cursor is not on the page. I am very curious to see an example where the multi-cursor is helpful.

It's the 4th video on the front page of https://sublimetext.com. We call it "Multiple Selections" there. Searching for "Sublime Text multi-cursor" on google yields plenty of websites and videos showing off use cases.

jfcherng commented 1 year ago

If I can only choose one feature for ST, I would choose "multiple cursors". 😄

danallendotcom commented 1 year ago

@BenjaminSchaaf , thank you for letting me know where to find use cases for the multi-cursor functionality. First use case: change variable names everywhere with one go, using multi-cursor. I can see how that would save a lot of time compared with the way I learned to change variable names, using search/replace. I searched for more examples and found them as you suggested. The examples seemed targeted for advanced programmers. I am afraid I have some basics to master before I could make good use of the feature. I feel guilty about all the work that has gone into a a feature I cannot put to constructive work.

@jfcherng I am known for having limited intelligence. I would like to compliment your ability to take advantage of this very important feature and thank you for bringing this to my attention.

I have a related question. I found a place in sublime, called settings, which contains strings that I am able to mistake for being similar in appearance to strings found in key bindings.

Settings look like this "close_find_after_find_all": true, "close_find_after_replace_all": true,

Key bindings are completely different and look like this: "keys": ["shift+backspace"], "command": "left_delete"

At first, I thought key bindings might be a kind of setting, but that is incorrect, yes?

No need to answer, I think I figured it out in the course of trying to explain it.