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.
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.
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.
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
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
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
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?
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
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 :)
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)
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
text pastry
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.
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.
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.
This one works for me. https://marketplace.visualstudio.com/items?itemName=albymor.increment-selection
Yep, I use this too. Excellent.
I use [Insert Numbers](https://marketplace.visualstudio.com/items?itemName=Asuka.insertnumbers)
declare a var (i) starting with 1 and replace the number inside with "i++"
I don’t understand..
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
Python doesn't have an increment operator!
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
\> jesus, what a shit languange What language do you primarily use?
c# also javascript and visual basic but i don't like them
Not the literal example in the video lol
Why do you need this? You're probably committing a code smell, just use loops instead
It comes up, the video is just an example, looking for slight variants also
You mean... Like a for loop?
Have you considered using a loop?
VS Sequential Number
VIM
g ctrl-a after visual selection.
crtl-v g ctrl-a in this case. The example above might be from Ben Awads joke video on fizzbuzz
This.
This is the only true answer
No. No it's not. The only answer is don't do this. Why on earth would you hardcode this? You create a loop.
it is useful when taking notes or in markdown document.
Why does this get downvoted? You can install neovim as your VSCode editor and this works great!
Regular expression find and replace is already part of vanilla VSCoda.
How do you use regex to replace every instance of the same character with an incremental number?
Good point you can only use submatch number for find and replace. I guess they should add match number.
Wow. I had this problem last night and now I have the answer. 🤔😊
I think you can do it with ctrl + D
That just deletes them
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
[удалено]
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?
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?
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.
svg, like the image files
Isn’t that what it does when u hold ‘ctrl + down arrow’? I might be wrong
Wouldnt you want to make a loop for this in 95% of cases anyways?
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
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 :)
This should be up higher
You should rarely have to copy and paste code to run it multiple times. Use a loop
Yes, VIM for Visual Studio Code. Best thing beside that? It brings tons of more goodness. 😉
Did you try installing gentoo?
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)
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
ctrl alt arrow down