Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 8 down vote accepted

You can do this (replace d with your command)



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
  • 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

Your Answer


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.