Visual Studio Code - How To Replace "X" with a list of data? - JSON

309 Views Asked by At

I have a question I need to code thousands of lines and instead of doing it manually I want to automate my work flow. So let me present you with some screenshots and a text example of what I am trying to achieve.

File 1 = "Blueprint": "XXX'", File 1 has several lines of that code above. Example Screenshot

I have a list of strings that I want to add each line to replace XXX value. I don't want my list to be pasted into a single XXX line I want to select all the lines containing XXX value and replace them with my list of strings. Each line should be placed into the XXX value itself.

Note: I understand I can replace all the "XXX" with a single replacement data but how do I replace each "XXX" with it's own unique line/data?

I attempted to do this using the visual studio code replacement but it only accepts single replacement data rather then using unique replacement line data.

1

There are 1 best solutions below

0
rioV8 On
  • in your list file go to the start of the file: Ctrl+Home
  • click on the last line with Shift+Alt+Click to place multi cursors
  • Press Home (start of the line) and then Shift+End (select every line)
  • Press Ctrl+C
  • Take note of the number of lines/cursors (lower left status bar)
  • in your JSON file, select first: "Blueprint": "XXX"
  • Press Ctrl+D as much as needed to get the same amount of cursors, you can use key repeat.
  • Press ArrowRight, ArrowLeft, Backspace, Backspace, Backspace (this deletes XXX)
  • Press Ctrl+V
  • Press Esc (sometimes multiple times, depends on what is shown) to get out of Multi Cursor

If you have more than 10000 places you have to do it in batches.