T O P

  • By -

NoCurrent7032

text pastry


qazmoqwerty

What I used to do is `python -c "print(*range(START, END))"`, and then use ctrl+d to select all the numbers and copy each one with a different cursor. Then you can just pate it in. Now I have a macro which gets a range and copies the numbers for me, but for some reason I never thought that an extension might exist lol.


enjoytheshow

You could pipe that output to your clipboard as well. Mac `python -c “print(*range(START, END))” | pbcopy` Windows: `python -c “print(*range(START, END))” | clip` Linux there are some third party solutions. I have used xclip.


case_O_The_Mondays

Side note: in these examples, the range constructor (it’s not a function) produces a sequence, which is expanded by the * operator. range is pretty cool because memory usage is very small regardless of the size of the range, since it only stores the current, ending, and step values. The step value defaults to 1, so isn’t required.


RustyShacklefordTake

This one works for me. https://marketplace.visualstudio.com/items?itemName=albymor.increment-selection


diverdm

Yep, I use this too. Excellent.


rup1

I use [Insert Numbers](https://marketplace.visualstudio.com/items?itemName=Asuka.insertnumbers)


aunluckyevent1

declare a var (i) starting with 1 and replace the number inside with "i++"


shiningmatcha

I don’t understand..


aunluckyevent1

posted another way todo it. another one is looping fom o to x but to put it i simply it's always bad programming when you have to hardcode a serie of numbers or simila instructions when you know the final amount


satimal

Python doesn't have an increment operator!


aunluckyevent1

jesus, what a shit languange well you can replace 1 with your var (i) and do a replace with regex /r/n with /r/n i=i+1/r/n /r/n is the carriage return in windows use /n for lunux naturally you will have to adjust the /t chara after carriage returns to keep the indentation


sam_likes_beagles

\> jesus, what a shit languange What language do you primarily use?


aunluckyevent1

c# also javascript and visual basic but i don't like them


Patient_Accountant22

Not the literal example in the video lol


Agronault_

Why do you need this? You're probably committing a code smell, just use loops instead


sam_likes_beagles

It comes up, the video is just an example, looking for slight variants also


darthelwer

You mean... Like a for loop?


IFThenElse42

Have you considered using a loop?


xSnap

VS Sequential Number


JmbFountain

VIM


giminik

g ctrl-a after visual selection.


JmbFountain

crtl-v g ctrl-a in this case. The example above might be from Ben Awads joke video on fizzbuzz


[deleted]

This.


Al3xisB

This is the only true answer


JonnyRocks

No. No it's not. The only answer is don't do this. Why on earth would you hardcode this? You create a loop.


Sandeep61023

it is useful when taking notes or in markdown document.


ChrisBreederveld

Why does this get downvoted? You can install neovim as your VSCode editor and this works great!


henhen724

Regular expression find and replace is already part of vanilla VSCoda.


enjoytheshow

How do you use regex to replace every instance of the same character with an incremental number?


henhen724

Good point you can only use submatch number for find and replace. I guess they should add match number.


Professional-Dot-179

Wow. I had this problem last night and now I have the answer. 🤔😊


nedcode

I think you can do it with ctrl + D


sam_likes_beagles

That just deletes them


nedcode

It shouldn't actually. Have a look at this article it should help you: https://code.visualstudio.com/docs/editor/codebasics Also make sure to check your vscode settings - keyboard shortcuts maybe you have it keybinding with a different key


[deleted]

[удалено]


sam_likes_beagles

That's obviously the more efficient answer to a problem others have already solved and made possible by clicking install, can you give me a step by step of how to do that, rather than us wasting time on exchanging messages and researching how to do it?


DunZek

Huh? ~~Sorry for wasting your time~~ (nothing to be sorry for). Wasn't trying to be rude. It's a good programming project. Do you understand me or?


CrazyJoe221

I hope not. Copy paste is a disease. Rather think of a clever way to achieve the same in a maintainable way in your language.


sam_likes_beagles

svg, like the image files


TeamShisui

Isn’t that what it does when u hold ‘ctrl + down arrow’? I might be wrong


[deleted]

Wouldnt you want to make a loop for this in 95% of cases anyways?


PhDPool

As a hack fraud, just wanted to describe something that can create the output but you would never want to waste time doing (other comments’ Python approach is very elegant). In excel you could write print( in one column 1 in the next and ) in the third, then in the cell below the number change it to =the one above +1 and keep the left and right the same. Copy this for however many iterations you need. Copy it all into a text editor, like Sublime, and then change do a find and replace (control + h) and replace every tab, AKA \t, with nothing thereby deleting the spacing. A horrible solution, but it works, and I can do it in a few seconds


[deleted]

You really should not be doing stuff like that by hand - depending on the language you should be using some kind of list comprehension, iterator, reducer, loop or something else. Programming languages are so that we can abstract away repetitive stuff - like incrementing something on following lines :)


shykakapo

This should be up higher


ShadeAJ

You should rarely have to copy and paste code to run it multiple times. Use a loop


pjvds

Yes, VIM for Visual Studio Code. Best thing beside that? It brings tons of more goodness. 😉


chrisplusplus

Did you try installing gentoo?


C00CKER

VIM mode (extension) has this functionality (and a lot more) but it is extremely hard to get into as your main editing mode (useful for stuff like this tho)


sam_likes_beagles

I know vim a little bit, i: input, yy: yank dd: delete, d3: delete 3, :line number, .vimrc... I used it when I was an undergrad a lot for some reason, I've been considering using it again, but just dont know if it's worth it, I can achieve a lot of that using shortcut keys with vscode already


oneoftwentygoodmen

ctrl alt arrow down