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

[Feature request] Sequentially shift numbers in consecutive lines #1

Open
daiplusplus opened this issue Jan 22, 2022 · 3 comments
Open

Comments

@daiplusplus
Copy link

daiplusplus commented Jan 22, 2022

Description

I'll often have many lines of code that should contain monotonically increasing integer values, 1 per line, often from copying+pasting a single line repeatedly, or from using the Duplicate Line command.

For example, I might have a multi-line SQL string that I've added column index numbers to (which are then used in SqlDataReader.GetFoobar(Int32) (I know I could use column-names, but sometimes it's just easier/simpler to use column ordinals), or a multi-line String.Format call with comments to remind me which args parameter argument corresponds to which format placeholder:

const String MY_SQL = @"
SELECT
    foo, -- 0
    bar, -- 1
    baz, -- 2
    qux -- 3
FROM
    table
";

using( SqlDataReader rdr = ... )
{
    String foo = rdr.GetString(0);
    Int32 bar = rdr.GetInt32(1);
    Decimal baz = rdr.GetDecimal(2);
    // etc
}

or:

String formatted = String.Format(
    format: "hello {0}, why don't you see {1} hiding in trees? because {2]. Why do {1} paint their toenails red? So they can hide in {3}. What's the loudest {4} in the {5}? {6} eating {7}",
    /*0:*/ "<yourName>",
    /*1:*/ "elephants",
    /*2:*/ "they're really good at it",
    /*3:*/ "cherry trees",
    /*4:*/ "sound",
    /*5:*/ "savanna",
    /*6:*/ "giraffes",
    /*7:*/ "cherries"
 );

...but originally those lines would have looked like this half-way through editing:

const String MY_SQL = @"
SELECT
    foo, -- 0
    foo, -- 0
    foo, -- 0
    foo -- 0
FROM
    table
";

...and...

String formatted = String.Format(
    format: "hello {0}, why don't you see {1} hiding in trees? because {2]. Why do {1} paint their toenails red? So they can hide in {3}. What's the loudest {4} in the {5}? {6} eating {7}",
    /*0:*/ , ""
    /*0:*/ , ""
    /*0:*/ , ""
    /*0:*/ , ""
    /*0:*/ , ""
    /*0:*/ , ""
    /*0:*/ , ""
    /*0:*/ , ""
 );

...respectively.

...so having some way of automatically incrementing identical integers in consecutive lines would be nice.


I'm happy to submit a PR for this functionality - though I've previously submitted PRs some of for your other projects but they're still sitting unread :(

@lordfanger
Copy link
Collaborator

Hi @daiplusplus,
can you update to 1.0.20 and check whether it satisfy your needs or not?

@daiplusplus
Copy link
Author

@lordfanger Wow, good stuff! 😃

I've just queued-up the 1.0.20 VSIX install (I can't restart VS right now, but I should have a chance to try it out tomorrow).

May I ask how you found my feature-request and what prompted you to build it? I guess you needed the same functionality?

@madskristensen Methinks the readme be reworded to better describe this feature as being like Excel's drag-auto-fill feature? (Now that makes me wonder if an Excel drag-fill handle could be added to ease discoverability and spontaneous use?)

@lordfanger
Copy link
Collaborator

Hi,
I was long time looking for that feature and then I found that extension that needed only a little tweak to support that scenario so I tried to create pull request. :)

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

2 participants