Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What's the syntax for selecting a range of lines?

I want to run a command over lines 1405 until 1700.

And one from 1405 until the end of file, without wanting to look up that number.

Update: Is it possible to select a range from the current line to Nth line?

share|improve this question

3 Answers 3

up vote 8 down vote accepted

You can do this (replace d with your command)

:1405,1700d

and

:1405,$d
share|improve this answer
  • Go to line 1405 by typing: 1405G.
  • Press V to switch to VISUAL LINE mode and then go to line 1701 by typing: 1701G.
  • Now your lines are selected, you can run a command on them. For example, to replace foo with bar type: :s/foo/bar/.
share|improve this answer

For your update: use .,N where N is the line you want.

(and in case you have further updates, check out :he range).

share|improve this answer
    
RTFM instead of just asking? Crazy concept :) But yeah, quite helpful indeed. –  k0pernikus Jan 26 '12 at 20:05
    
worth a look :) –  Edd Steel Jan 26 '12 at 20:20

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.