Delimiter in :substitute

Your :substitute command deserves better than \/\/\/

Apr 30, 2026

The :substitute command uses / as its delimiter by default, but it doesn't have to. You can use any single-byte character that isn't alphanumeric, /, ", or |.

This becomes painfully obvious when renaming paths. Using / as the delimiter forces you to escape every slash in the pattern and replacement:

:%s/src\/components\/Button/src\/ui\/Button/g

Swap the delimiter to , and the same command becomes immediately readable:

:%s,src/components/Button,src/ui/Button,g

The same applies to :global and :vglobal you can replace the / surrounding the pattern with any character there too. See :help pattern-delimiter for the details.

Share

Comments (0)