1

I just came across this example in Learning the vi and Vim Editors:

.Rh 0 "Get status of named file" "STAT"
.Rh "SYNTAX"
 ...
.Rh "DESCRIPTION"
 ...
.Rh "PARAMETERS"
 ...

The command to move DESCRIPTION above the SYNTAX paragraph is given by

:g /SYNTAX/.,/DESCRIPTION/-1 move /PARAMETERS/-1

The explanation given is: First, ex finds and marks each line that matches the first pattern. Second, for each marked line, it sets . (dot, the current line) to that line and executes the command.

But why do we need the dot after /SYNTAX/? Is it a special syntax for the g command?

1

:g takes a command after its pattern. :m is the command, and it takes a range before it. . is the beginning of that range.

  • I see, so :g will automatically set . to the line that matches the pattern? – Yang Jun 29 '13 at 5:22
  • 1
    The pattern will become the current line being operated on. – Ignacio Vazquez-Abrams Jun 29 '13 at 5:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.