Solutons Lounge

How to substitute URLs? – Vi and Vim Stack Exchange


I would do:

:%s!https://example.com!https://placehold.co/64!g

Or even better:

:%s!\Vhttps://example.com!https://placehold.co/64!g

To avoid to match https://exampleOcom since without the \V flag the . match any character (e.g. O in the example).

More information with :help /magic

The | is a very special character in the Vim command used to chain command. You should not use it a substitute separator (I prefer using ! when not using /).

For pattern separator you can use any character but:

  • an alphanumeric character,
  • \,
  • " or
  • |

More information with :help pattern-separator



Source link

Exit mobile version