When I press
: from visual mode, the command line is pre-populated with
:'<,'>. It seems to affect how my substitutions work.
What do the characters mean and why are they inserted?
:'<,'>s/foo/bar/g differ from
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.Sign up to join this community
The substitute command can accept a range prefix. Without it, like:
Will just substitute on the current (cursor) line.
Will substitute on the whole file.
Will substitute on lines 5 through 10, inclusive.
When you visually highlight some text, there are two marks that are automatically updated, mark
< denoting the beginning of the visual area and
> the end. When you have something visually selected and press
: Vim assumes you want to do whatever command you're about to type on the visual area, so it pre-populates the command line.
:help cmdline-ranges for more information on ranges, and
:help mark-motions for more information on the various marks that can be used.