2

I want to substitute this word ${ARRAY1[@]} with $1 on vim substitution command I did

:%s:\$\{ARRAY1[\@]\}:\$1:g

But give me error about number of repetition,i try also "" but doesn't work How to do? Thanks

2 Answers 2

3
:%s/\${ARRAY1\[@\]}/$1/

worked for me. Apparently, you must escape [ and ] but not { and }. I always use / instead of : as seperation, but

%s:\${ARRAY1\[@\]}:$1:g

works as well.

1
  • To figure out what should or should not be escaped, read the vim documentation on the magic option: :help 'magic'.
    – jw013
    May 19, 2015 at 16:02
2

Try this way:

:%s:\${ARRAY1\[@\]}:$1:g

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.