Skip to main content
added 7 characters in body
Source Link
saginaw
  • 6.9k
  • 2
  • 27
  • 47

Certainly looks like a case for a macro

  • /array<CR> to jump to the first array
  • qq to record the macro into register q
  • de to delete the word array
  • ma to save the cursor position on the first bracket at mark a
  • %r] to jump to the matching bracket, replace it by another bracket
  • `ar[ `ar[ to jump back to position a and replace that bracket
  • q to end recording of the macro

After that, it's just repeatedly pressing n to jump to the next match and @q to play the macro. You could make the search part of the macro and just execute until it stops, but I thought you might prefer to visually check each substition... you choose :)

Certainly looks like a case for a macro

  • /array<CR> to jump to the first array
  • qq to record the macro into register q
  • de to delete the word array
  • ma to save the cursor position on the first bracket at mark a
  • %r] to jump to the matching bracket, replace it by another bracket
  • `ar[ to jump back to position a and replace that bracket
  • q to end recording of the macro

After that, it's just repeatedly pressing n to jump to the next match and @q to play the macro. You could make the search part of the macro and just execute until it stops, but I thought you might prefer to visually check each substition... you choose :)

Certainly looks like a case for a macro

  • /array<CR> to jump to the first array
  • qq to record the macro into register q
  • de to delete the word array
  • ma to save the cursor position on the first bracket at mark a
  • %r] to jump to the matching bracket, replace it by another bracket
  • `ar[ to jump back to position a and replace that bracket
  • q to end recording of the macro

After that, it's just repeatedly pressing n to jump to the next match and @q to play the macro. You could make the search part of the macro and just execute until it stops, but I thought you might prefer to visually check each substition... you choose :)

Source Link
PhilippFrank
  • 1.2k
  • 9
  • 13

Certainly looks like a case for a macro

  • /array<CR> to jump to the first array
  • qq to record the macro into register q
  • de to delete the word array
  • ma to save the cursor position on the first bracket at mark a
  • %r] to jump to the matching bracket, replace it by another bracket
  • `ar[ to jump back to position a and replace that bracket
  • q to end recording of the macro

After that, it's just repeatedly pressing n to jump to the next match and @q to play the macro. You could make the search part of the macro and just execute until it stops, but I thought you might prefer to visually check each substition... you choose :)