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

x selects the next line when on an empty line #2206

Closed
glguy opened this issue Jul 10, 2018 · 8 comments
Closed

x selects the next line when on an empty line #2206

glguy opened this issue Jul 10, 2018 · 8 comments

Comments

@glguy
Copy link

glguy commented Jul 10, 2018

x selects the next line when on an empty line, which means that in order to know how to delete a line I need to know if that line has spaces or not. If it has spaces I have to press xd but if it does not have spaces I would have to press only d because x on a blank line selects the next line.

This seems to make the behavior of x unpredictable and harder to use. Is this intentional? I'd prefer if x always selected the line that the cursor was on, even if that line was empty.

@alexherbo2
Copy link
Contributor

map global normal x <a-x>

@maximbaz
Copy link
Contributor

Good workaround for now, but I would still argue that both x and especially X need to be made consistent. x is documented as "select a line", so why doesn't it select an empty line? X is documented as "extend line", but when pressed on a non-empty line it selects one line, and when pressed on an empty line, it actually selects two lines, the current empty one and the next non-empty line.

@alexherbo2
Copy link
Contributor

An empty line is nothing but a new line character, so when pressing x on it, it moves to the next line – the line being fully selected. The same goes for X.

  • x selects a full line and if satisfied moves.
  • X selects a full line and if satisfied extends.

There are corner cases where the commands don’t select the full line and move or extend.

@maximbaz
Copy link
Contributor

I see your point and the reasoning behind the current behavior, but I still think we should improve it 🙂

A new line character is still a character, so when pressing x or X, it should be selected. In fact, if you are on a non-empty line, pressing x and X selects all characters, including a new line character (you can see this by pressing d, it doesn't leave an empty line behind).

So I would say, the expected behavior is:

  • x selects all characters (including a new line char) on the current line (or on the next line, if the entire line was already selected)
  • X extends selection by selecting all characters (including a new line char) on the current line (or on the next line, if the entire line was already selected)

Also, currently x and X skip only one empty line, even if I have multiple consequent empty lines, which again feels inconsistent even if we agreed to treat new line character as a non-character.

@mawww
Copy link
Owner

mawww commented Jul 12, 2018

x selects the full line, if the full line is already selected, it selects the next line, this is pretty simple, and there is <a-x> which drops the "smart" part (select next line if the current line is already fully selected).

I think this is a pretty good tradeoff between ease of use, simplicity and predictibility. I am dubious we can find a better one.

@maximbaz
Copy link
Contributor

I think I understood my own confusion... Contrary to vim where selection starts only when you switch to a visual mode, in kakoune we are always in a visual mode. Having a cursor always means something in selected. So in case of cursor standing on an empty line, the newline symbol (under cursor) is a selection, and since there are no more characters on the line, this entire line is literally being selected right now.

From this perspective, what I described as "expected behavior" is also the actual behavior that happens today: x selects all characters on the next line, because the current line is already selected.

With this in mind, I personally think nothing should change in kakoune and this issue should be closed. It's just a mind shift that needs to happen, remember that we are always in visual mode.

@alexherbo2
Copy link
Contributor

@mawww As a side note, X doesn’t select the full line when selections are left oriented.

@mawww
Copy link
Owner

mawww commented Jul 14, 2018

@alexherbo2 Yep, extending has a simple behaviour, it keeps the anchor in place, which gives this behaviour if the line selection is inverted.

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

No branches or pull requests

4 participants