i want to change multiline string within particular marks that is indented in file, example looks like this:

```
    non_important_array: [
    text
    ],
    important_array: [
    text1,
    text2,
    text3
    ],
    non_important_array: [
    text
    ],

```

my goal is to be able to replace `important_array` with my multiline string

```
    my_array: [
    my_text1,
    my_text2
    ],

```

so i would like to have it like so:

```
    non_important_array: [
    text
    ],
    my_array: [
    my_text1,
    my_text2
    ],
    non_important_array: [
    text
    ],

```

but there could be also a variation, and it will look like this:

```
    non_important_array: [text],
    important_array: [text1,text2,text3],
    non_important_array: [text],

```

and the output should be looking similar as expected above

```
    non_important_array: [text],
    my_array: [
    my_text1,
    my_text2
    ],
    non_important_array: [text],

```

Right now im trying to make this work with `sed`, but it's taking last occurance of `]` and i dont know how to correct that

```
sed -i '' '/\s*important_array.*/,/\]/c\
    my_array: [\
    my_text1,\
    my_text2\
    ],' file.txt

```

Thanks!

EDIT:

* one liner would be much appreciated
* i want to replace it inplace, to have the same file modified