Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
    
I see, so :g will automatically set . to the line that matches the pattern? –  Yang Jun 29 '13 at 5:22
    
The pattern will become the current line being operated on. –  Ignacio Vazquez-Abrams Jun 29 '13 at 5:22
    
Got it, thanks! –  Yang Jun 29 '13 at 5:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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