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

Line text objects for selecting line with and without indents #4234

Open
sudormrfbin opened this issue Oct 12, 2022 · 4 comments
Open

Line text objects for selecting line with and without indents #4234

sudormrfbin opened this issue Oct 12, 2022 · 4 comments
Labels
A-keymap Area: Keymap and keybindings C-enhancement Category: Improvements

Comments

@sudormrfbin
Copy link
Member

sudormrfbin commented Oct 12, 2022

Would it be reasonable to request the following as an addition to the Match mode?

mal identical to x (maybe include prepended indentation)
mil identical to x_

The mnemonics in Helix are really good and adding these makes sense IMO.

Originally posted by @superDuperCyberTechno in #4225 (comment)

@sudormrfbin
Copy link
Member Author

sudormrfbin commented Oct 12, 2022

Copy pasting my comment from the discussion:


These exact keybinds have been on my mind for some time, with the difference that mal would select the line without the ending newline (whereas x selects with the new line).

Another idea would be to have:

  1. alt-x as x_ (which removes indentation and newline from selection) and alt-X as x without newline (keeping indentation intact).

    This would require moving the shrink_to_line_bounds keybind from alt-x to some other key, but makes it easier to do things like alt-x c to mimic vim's cc.

  2. Or we could move shrink_to_line_bounds from alt-x to alt-X (which pairs with extend_to_line_bounds that is actually on X) and have only x_ bound to alt-x.

@sudormrfbin
Copy link
Member Author

sudormrfbin commented Oct 12, 2022

The main selling point I see is for doing things like "change current line" where you might want to keep the line's current indentation but change the text (which means x cannot be used) or delete everything but put the cursor on the same line in insert mode. x will select the whole line (including newline) so xc will delete all of the line and put the cursor on the start of the next line, which is undesirable here. x_ does the job but something like mil is easier to grok.

@pascalkuthe pascalkuthe added C-enhancement Category: Improvements E-easy Call for participation: Experience needed to fix: Easy / not much A-keymap Area: Keymap and keybindings labels Jan 2, 2023
@taupiqueur
Copy link
Contributor

There is a good rationale from @Delapouite for introducing line text objects: https://github.com/Delapouite/kakoune-text-objects

@raffimolero
Copy link

raffimolero commented Feb 11, 2023

here's a bind for now.
EDIT: this uh, removes all the other "match in" and "match around" commands...

[keys.normal]
m.i.l = ["goto_first_nonwhitespace", "select_mode", "goto_line_end", "normal_mode"]
m.a.l = ["goto_line_start", "select_mode", "goto_line_end", "normal_mode"]

on a similar note, can we switch x with X by default? i find extend_to_line_bounds a more common operation than extend_line_below. there must be an existing discussion for this somewhere.

i'd find it easier to delete empty lines if i didn't have to either

  1. remember that xd on empty lines deletes two lines, or
  2. use Xd which requires me to release shift for d by default.

this can also be solved by also making D delete, which is my current config, which lets me hold right shift to type XD, or by rendering newlines and just keeping track.

@kirawi kirawi added the E-good-first-issue Call for participation: Issues suitable for new contributors label Oct 17, 2023
@the-mikedavis the-mikedavis removed E-easy Call for participation: Experience needed to fix: Easy / not much E-good-first-issue Call for participation: Issues suitable for new contributors labels Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-keymap Area: Keymap and keybindings C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

6 participants