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 selection increment #3910

Closed
MGlolenstine opened this issue Sep 20, 2022 · 9 comments
Closed

Multiple selection increment #3910

MGlolenstine opened this issue Sep 20, 2022 · 9 comments
Labels
A-core Area: Helix core improvements C-enhancement Category: Improvements E-good-first-issue Call for participation: Issues suitable for new contributors

Comments

@MGlolenstine
Copy link

Summary

data[0] = 15;
data[0] = 15;
data[0] = 15;
data[0] = 15;
data[0] = 15;

and I'd like to increment them as such.

data[0] = 15;
data[1] = 16;
data[2] = 17;
data[3] = 18;
data[4] = 19;

if I select all of the 15s but the first one and press C-a, it increments them all to 16 and not like I want.

Reproduction Steps

  1. Open a file in helix
  2. Paste the above text into it
  3. Navigate to 15, press e and C few times to select all 15s.
  4. Press C-a, which increments numbers.
  5. This results in all numbers becoming 16s and not being incremented from 16-19 as expected.
  6. Same happens for decrements.

Helix log

Helix log is empty.

Platform

Linux

Terminal Emulator

Kitty

Helix Version

helix 22.08.1

@MGlolenstine MGlolenstine added the C-bug Category: This is a bug label Sep 20, 2022
@CptPotato
Copy link
Contributor

To my knowledge this is actually the intended behavior, not a bug. Increment doesn't produce a range but increments each selected number separately.

Though, I've been in a similar situation where I wanted to generate a range of numbers a few times. For reference, Sublime Text has plugins such as Text Pastry that enable this.

@MGlolenstine
Copy link
Author

Interesting. I thought it would be the same way as it is with Vim. g <C-a>

@kirawi kirawi added C-enhancement Category: Improvements A-core Area: Helix core improvements E-good-first-issue Call for participation: Issues suitable for new contributors and removed C-bug Category: This is a bug labels Sep 20, 2022
@Omnikar
Copy link
Contributor

Omnikar commented Sep 21, 2022

One way to achieve the desired behaviour here would be to make sure the top selection is the primary one (using () as needed), and alternate C-a and A-, until there is 1 selection left. This could also be sped up using a macro.

@dead10ck
Copy link
Member

Yeah as far as I know this is expected behavior. This could definitely be a new command though.

@MGlolenstine
Copy link
Author

I'd love to work on implementing command like this, but I'll need some hand-holding, as I'm new to the codebase.

@olafmustafar
Copy link

@MGlolenstine This is a change you can make in the increment_impl function inside the src/commands.rs to make the increment function behave like vim's g+ :
image
I'm not sure if there is a better way to do this since I'm new to this project and also new to rust.

If we are going to implement this there is still the need to define which shortcut we can use.

@Bruce-Hopkins
Copy link
Contributor

The PR opened should fix the issue, but it changes the way the increment works. I'm thinking about making this another command, but I don't know what that would look like.

@kirawi
Copy link
Member

kirawi commented Jun 5, 2023

Resolved by #4418. This is the behavior when the register is #, so #C-a or #C-x would do it.

@kirawi kirawi closed this as completed Jun 5, 2023
@gabydd
Copy link
Member

gabydd commented Jun 5, 2023

Should we specify in the docs that "#C-a/"#C-x has this behaviour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Helix core improvements C-enhancement Category: Improvements E-good-first-issue Call for participation: Issues suitable for new contributors
Projects
None yet
Development

No branches or pull requests

8 participants