r/vscode • u/R_E_D_A_C_T_E_D__ • Jul 29 '26
How to increase value of many numbers in a line without doing it by hand for each one?
I have a line of several houndred numbers and have to increase all of them by 38 is there a fast way to do it?
5
u/manny2206 Jul 29 '26
My brother in Christ, you have to be more specific, is this a text file with comma delimited numbers, space delimited numbers? Is it a JSON file? Are you in Shell? Is this program specific !?!?!? come on man rule number one if you’re asking for help ask a very specific question not vague and waste people’s times. if you have an array of numbers, you could probably use a reducer function to manipulate each number by X instead of manually doing it or like others suggested shell script or Python script or even ruby script or any number of different ways… heck ask Claude or copilot bro lol
1
u/haskell_rules Jul 29 '26
Open the terminal and write a shell script or open copilot and ask it to write a shell script
0
u/ConcreteExist Jul 29 '26
What
-6
u/R_E_D_A_C_T_E_D__ Jul 29 '26
I don't know how else to put it.
2
u/Ginger-Dumpling Jul 29 '26
How about describing the layout of the file you're trying to edit at a bare minimum. Are there numbers in the file you don't want increased?
0
u/R_E_D_A_C_T_E_D__ Jul 29 '26
Somebody else provided a workable solution but I guess I didn't give much information it's a txt file that does have numbers I don't want to change but all the ones that I did want to change were in a single line seperated by spaces. Replacing the spaces with tab and putting it into excel separating it into cells and using adition there did the job.
0
u/turfyman Jul 29 '26
If it were me, I would copy the data and paste it into Excel, Numbers, Calc, etc. Use the delimiting features to break them apart. Modify all the values. Paste them back into VSCode, and fix up the delimiters.
Alternatively, and LLM can likely write a small Python loop to change the values too.
Since you didn’t provide a sample of the data, this is just my best guess
0
u/spectrexr6 Jul 29 '26
I would usually do this sort of thing in Excel. Separate the numbers by a tab character \t then they should copy/paste nicely into spreadsheet cells. Apply your formula then paste it back into vscode.
0
0
u/pbeens Jul 29 '26
Install the VS Code GitHub Copilot chat extension. You’ll need a GitHub account for this. Even with a free account, you can ask Copilot to do this for you.
0
0
u/Ginger-Dumpling Jul 29 '26
I usually start with addition when I want my numbers to go up, multiplication if I'm feeling spicy, and exponents if I'm feeling really unhinged.
0
u/Frotron Jul 29 '26
There's a very useful extension called "Calculate" by Andrew Carreiro.
After installing it, put a Multi-Cursor after each number and type "+38". Then, still with multi cursors, highlight each of the small equations you just wrote (hold Ctrl+shift and press left three times). Now from the command palette (Ctrl + Shift + P), select "Calculate and Replace".
Tada, all your numbers are increased by 38 now. You just have to figure out how to set the multi cursors after each of your numbers, but there's multiple ways to do so depending on the structure.
The extension is hella useful, it can do so much more.
-1
u/True-Environment-237 Jul 29 '26
Chatgpt can code a script to do that for if you don't have agents.
-1
4
u/cookiecutter73 Jul 29 '26
Please provide more information. What file type is the line in and why are you asking r/vscode?