in VS Code there is an extension "Increment Selection" to increment numbers in the code. Does it exist for Visual Studio Community too?
Asked Answered
E

5

14

Sometimes I have code where I have to insert consecutive values. This is a problem with big files. First I make them all the same, after which I increase the value 1 by 1.. Such as:

<div>a1</div>
<div>a1</div>
<div>a1</div>
<div>a1</div>
<div>a1</div>
<div>a1</div>`

becomes:

<div>a1</div>
<div>a2</div>
<div>a3</div>
<div>a4</div>
<div>a5</div>
<div>a6</div>
Eozoic answered 20/5, 2019 at 17:45 Comment(0)
E
13

Found sort of an answer by installing VS-Code; install "Increment Selection" and reload file in VS-Community.

Eozoic answered 20/5, 2019 at 19:5 Comment(0)
D
10

You can try out Emmet abbreviation feature in Visual Studio Code.

According to Emmet in Visual Studio Code - visualstudio.com, Emmet is a build-in feature in Visual Studio Code. No extension is needed!

Emmet snippets and expansions is build right into Visual Studio Code.


Example

  1. Type following characters on Visual Studio Code in a html file (or any file supported by this feature, see more).
    div{a$}*6
    
  2. Press Tab. It will expand Emmet abbreviations to this:
    <div>a1</div>
    <div>a2</div>
    <div>a3</div>
    <div>a4</div>
    <div>a5</div>
    <div>a6</div>
    

You can find more Emmet syntax on Emmet Documentation - emmet.io.

Dromedary answered 21/4, 2021 at 21:31 Comment(7)
this is the answer.Carbonado
@Carbonado what's going on here?Stokehold
This isn't the answer. This is for creating new incrementing divs, not changing existing values like OP asked. Emmet seems to have some functionality like OP is looking for, but for me, when multi-selecting a list of numbers, it increments each one equally. eg. a list or 1, 1, 1, 1, 1, becomes 2, 2, 2, 2, 2, which has little to no value for me or OP's use case. Maybe there's a way to do it, but I don't see it. The VSCode Progressive Increment extensions offers the desired functionality.Bacteriophage
@Carbonado how u landed here?Dromedary
@JoelMellon Thanks for your elaboration to the issue . Try using regex for that particular scenario. or use the following Extension [marketplace.visualstudio.com/…. Ctrl + D Or Hold Alt +Shift and Drag mouse to select and Alt + Click to deselect.Dromedary
@AliTasawar did I do something wrong?Carbonado
@Carbonado Not at all👍Dromedary
G
6

Check out the Incrementor plugin, it works on various cases.

Guenevere answered 20/5, 2019 at 17:47 Comment(2)
It is marked "VSCode Extension"... not for VSCommunityEozoic
it kind of does a different thing, it doesn't allow incrementing different lines by different amountsSedum
S
2

Another extension that will do the job is VSCode Progressive Increment. I think is more user friendly than "Increment Selection" (mentioned in an answer by @backnext) since it doesn't require multiple cursors.

Saldana answered 4/8, 2022 at 13:19 Comment(1)
Not "another", it's the only one I've found that does the job specified by OP. This should be the accepted answer.Bacteriophage
V
0

Check out Text Text Power Tools which allows you to insert a number sequence with custom starting point and at custom increments. It also allows you to do a bunch of other stuff like make a selection upper or lower case, as well as inserting lorem ipsum paragraphs, encoding, line sorting, etc

Valladares answered 30/10, 2022 at 23:24 Comment(1)
Seems to be nice but again "VSCode Extension"... not for VSCommunityEozoic

© 2022 - 2024 — McMap. All rights reserved.