Question for vim power users:
file1.txt
Some list
- line 1
- line 2
Example of payload:
```json
{
"order_id": "ABC123",
"postcode": "A1 B22",
"items": [1, 2, 3]
}
```
More text follows.
My goal is to:
- match everything that is in between
```jsonand``` - get rid of those prefix/suffix
- and prepend each line with extra spaces (add indentation). The result would be something like that:
file2.txt
Some list
- line 1
- line 2
Example of payload:
{
"order_id": "ABC123",
"postcode": "A1 B22",
"items": [1, 2, 3]
}
More text follows.
So far I managed to non-greedy match everything between json and backticks via:
%s/```json\(\_.\{-}\)```/\1/g
But prepending each line of \1 is an entirely different story.
Things I experimented with is:
- submatch (i.e.
%s/```json\(\_.\{-}\)```/\=submatch(1)/g) - trying to chain replaces (but I have no idea how to do it)
Any help/suggestion?