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

BUG: Multiple cursors + Word wrap #1054

Open
forthrin opened this issue Dec 28, 2015 · 19 comments
Open

BUG: Multiple cursors + Word wrap #1054

forthrin opened this issue Dec 28, 2015 · 19 comments

Comments

@forthrin
Copy link

forthrin commented Dec 28, 2015

  1. Turn on Word Wrap
  2. Open a text file with some ten adjacent lines, where some of the lines wrap to the next line
  3. Hold alt and drag the mouse down on the left side of the text to create multiple cursors (on Windows and Linux, its shift+right click and drag)
  4. Start typing or erasing

Rather than editing each single line as expected, Sublime Text starts editing the continuation lines (the excess of the wrapped lines) too, with text havoc ensuing shortly. Surely this must be a bug.

I assume the correct behaviour is to put multiple cursors only at the actual beginning of the lines, leaving the continuation lines untouched.

Not surprisingly, the problem does not happen when Word Wrap is turned off.

@FichteFoll
Copy link
Collaborator

Don't think this actually is a bug but rather a feature. It's also the more visual approach because making a column selection with the continuation of wrapped lines not selected looks weird, probably.

@forthrin
Copy link
Author

It wouldn't be perceived weird at all, if you ask me.

The results the way things work now are unexpected to say the least. When you type the first character (let's say a hash character: "#"), further word wrapping may occur on some lines because of the added character (causing the word on the end of a line to jump to the beginning of the second line), so the hash characters you type appear all over the place. This could never be anyone's intention.

So to avoid this, I have to turn off word wrapping, do what I want to do, and then turn it back on. It seems cumbersome and unnecessary.

If for some reason, a fix cannot be implemented, is there another approach to marking only the n'th actual character (regardless of word wrapping) of a set of consecutive lines, without turning word wrapping off?

@FichteFoll
Copy link
Collaborator

If for some reason, a fix cannot be implemented, is there another approach to marking only the n'th actual character (regardless of word wrapping) of a set of consecutive lines, without turning word wrapping off?

Can't think of a reason, but I also don't know the code so it could be anything.

Since this selection is based on mouse events and mouse events are terribly bad to interface atm (compared to the rest), there probably isn't much you can do.

@forthrin
Copy link
Author

I'll wait for a developer to comment on this. This still comes off as a bug to me.

@Neospiro
Copy link

Is there another approach to marking only the n'th actual character (regardless of word wrapping) of a set of consecutive lines, without turning word wrapping off?

Two methods :

  • CTRL/CMD+F and type ^.{n} in search bar (with regexp activated; this is the 1st option) ; this will find the first n chars of each lines. Press ALT + Return to select and -> to have a cursor,

If you want to learn more about this feature, search "regexp"

  • ^ is for "start of line"
  • . is for "all character"
  • {n} mean "n times" ;

so ^.{2} will find the 2 first characters on each lines

  • Select your lines (traditional way), CTRL+SHIFT+L to have 1 cursor on each selected lines, home twice to go to the beginning of each line and type N times ->.

Try to find another way to wrap text (in the file, not only on screen) without your bug/feature :

  • Toggle word wrap ON
  • holding ALT, Select with your mouse the n first char of each wrapped lines (your bug)
  • Type Shift+End to select entire wrapped lines
  • Type CTRL+X,V to paste each wrapped line on it's own line.
    • If your had multiple lines wrapped, this will duplicate your text, type "home" before pasting to avoid that.

Now you can toggle off word wrap and your text is still wrapped. I find this usefull when I have plain text in code.

So I don't think this is a bug : I think you try to write using a mouse, and this behaviour is unexpected.

Sorry for my bad english, love from France

EDIT : CTRL+L to CTRL+SHIFT+L + duplicates' note

@forthrin
Copy link
Author

Couldn't quite get any of these to work.

I get the search for ^ (I'm quite proficient in regex), but this finds every single line in the file, whereas I only want maybe 20 consecutive lines. Also Ctrl+L and Ctrl+X seems to do nothing in your examples.

A typical example would be to get a cursor at the asterisk character of line 1-4. How do I do this with word wrapping on where the blah's will wrap to the next line with a narrow enough window.

SECTION ONE
* Line 1 blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah bblah lah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
* Line 2 blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah bblah lah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
* Line 3 blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah bblah lah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
* Line 4 blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah bblah lah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 

SECTION TWO
* Line 5 blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah bblah lah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
* Line 6 blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah bblah lah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
* Line 7 blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah bblah lah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
* Line 8 blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah bblah lah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah 

Votre anglais est probablement mieux que mon français :)

@Neospiro
Copy link

whereas I only want maybe 20 consecutive lines.
Select your 20 lines and check "search in selection" before searching for ^.
This is never checked by default except with "auto_find_in_selection":true, in your config file ; that will check search in selection everytime you start a search with a selection containing a line break.

There is an alternative method : Cut your 20 lines and work with on a new file. Search for ^ will only affect your 20 lines 😉 . I work a lot on snippets like that

Also Ctrl+L and Ctrl+X seems to do nothing in your examples.
I failed : try with CTRL+SHIFT+L

( with the default
{ "keys": ["ctrl+shift+l"], "command":"split_selection_into_lines" }
in your config key map file )

( I edited my previous answer )

There is a LOT to learn about sublime. I use it everyday, know some tricks, and still feel as a noob :p

@forthrin
Copy link
Author

Selecting the area, pressing Cmd+Shift+L, then Cmd+Left Arrow does exactly what I want. Thanks! Yes, it seems like the kind of app where they add new features faster than you can learn them.

I'll let a developer decide whether the current state of vertical marking with the mouse should be considered a bug or not.

@evandrocoan
Copy link

This is a bug or a feature? All bugs are features, so I would like to enable or disable this feature by setting.

bug

@keith-hall
Copy link
Collaborator

keith-hall commented Oct 9, 2016

In regards to the OP, this behavior applies to all caret related interaction with word wrap - press down and the cursor goes to the soft line, same with Selection -> Add Next Line etc. i.e. Its not just related to column selection with the mouse. So that's why it's not a bug, although I agree that it isn't always want one wants.

@FichteFoll
Copy link
Collaborator

FichteFoll commented Nov 7, 2016

The setting to disable this feature is word_wrap.

@evandrocoan
Copy link

evandrocoan commented Nov 7, 2016

Yeah, I like this behavior and basically I can disable and enable this behavior without turning the word_wrap, just installing the Package:

  1. https://packagecontrol.io/packages/Column%20Select

And I remapped my keyboard to:

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

    // Sublime Column Select, https://github.com/ehuss/Sublime-Column-Select
    { "keys": ["shift+alt+up"], "command": "column_select", "args": {"by": "lines", "forward": false}},
    { "keys": ["shift+alt+down"], "command": "column_select", "args": {"by": "lines", "forward": true}},
    { "keys": ["shift+alt+pageup"], "command": "column_select", "args": {"by": "pages", "forward": false}},
    { "keys": ["shift+alt+pagedown"], "command": "column_select", "args": {"by": "pages", "forward": true}},
    { "keys": ["shift+alt+home"], "command": "column_select", "args": {"by": "all", "forward": false}},
    { "keys": ["shift+alt+end"], "command": "column_select", "args": {"by": "all", "forward": true}},

So, now using alt+left I got this behavior:

And Using alt+shift+left I got the requested behavior on this issue:

not_hang2

Now seems this issue purpose has been fulfilled and may be achieved just installing a already existent package. Or there is something missing which the Package Column Select could not complete?

@shmolf
Copy link

shmolf commented May 25, 2018

I'm still experiencing @evandrocoan 's issue today. I'm going to try his solution when I get home.

@valeriesubl
Copy link

valeriesubl commented Jun 26, 2023

We're planning on adding some alternative "wrap aware" behavior but I wanted to gather some thoughts on this first.

In the following situation when adding a 2nd cursor below via the keyboard (ctrl+alt+down on Windows):
where do you expect the new cursor to be?
image

A: End of line 2. The line isn't long enough to have 4 soft-wrapped lines so we place it at the end instead.

or

B: Near the end of line 9, on the 4th soft-wrapped line. Lines 2-8 aren't long enough to have 4 soft-wrapped lines so we skip over them entirely.

The Column Select package goes with option B I believe.

Of course we could add the option for both but I wanted to hear people's expectations regarding this behavior

@Jackenmen
Copy link

I would expect option A, the ctrl+alt+down shortcut (whatever it's called) always seemed to create a cursor in next line so I would be very surprised if in some cases it would instead show up a few lines later.

@deathaxe
Copy link
Collaborator

I'd also expect option A (and would have expected Column Select to do so as well).

Maybe not a good idea in word wrapped lines, but I could also imagine use cases it might make sense to append spaces to a line which is not long enough (as AlighCursors does). Actually AlignCursors could be used to achive that.

@evandrocoan
Copy link

I would expect it to visually follow what is on the screen (what you see is what you get, WYSIWYG). And when disabling the word-wrap, I also would expect it to WYSIWYG again, but now with a new behavior according to what you see is what you get.

@evandrocoan
Copy link

Actually, I take that back. The behavior I see today with my Sublime Text installation is not WYSIWYG. So, I am just not sure about what to expect anymore.

@deathaxe
Copy link
Collaborator

IMHO, the most problematic aspect of current behavior with regards to insufficient line lengths is it causing amount of cursors per line to change (#1558).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants