ovatsug25
ovatsug25

Reputation: 8596

what does '&' mean when used in a vim regex?

What does '&' character mean when used in a vim regex like so:

:s/pattern/  /g

Upvotes: 0

Views: 267

Answers (1)

ovatsug25
ovatsug25

Reputation: 8596

When used in a find and replace command '&' refers to what was found in the document. It is a way of reprinting whatever you looked up.

This:

:s/pattern/  /g

would thus return:

patternnbsp;patternnbsp;

You can escape it like any other VIM metacharacter:

:s/pattern/\ \ /g

You can find more information here on Backreferences: http://vimregex.com/#backreferences

FYI:   refers to a non-breaking space in HTML

Upvotes: 3

Related Questions