Sorry I am still a beginner but slowly getting there. I want to change all the "base-purchase-prices" by a % all at once? I am tearing my hair out trying to work out how to do it. There are 7000 line items so simply saying "get a calculator" is not going to work
{
"tradeable-code": "Scissors_01",
"base-purchase-price": "110",
"base-sell-price": "12",
"delta-price": "-1.0",
"can-be-purchased":"default"
},
{
"tradeable-code": "Scissors_Plastic",
"base-purchase-price": "88",
"base-sell-price": "9",
"delta-price": "-1.0",
"can-be-purchased":"default"
},
2
Answers
You can use the extension Regex Text Generator
base-purchase-price
prices(?<="base-purchase-price": ")([^"]*)
Alt+Enter
while focus in Find dialog(.*)
{{=N[1]*1.05:fixed(2):simplify}}
Enter
otherwiseEsc
Esc
to leave Multi Cursor ModeUsing this extension: Find and Transform, full disclosure – written by me, it is easy to do math on any values in your file.
For example, make this keybinding, in your
keybindings.json
file (it could also be made into a setting that will become a command in the Command Palette if you want:The
find
will capture only the digits you want to change. Thereplace
will run any math (or string) operation you want. Here I simply multiplied the capture group$1
by 1.05 and set it to 2 decimal places.