vim I can write a range of lines from the file I'm viewing to another file. For example,
:1,10 w outfile.txt
will write lines 1 through 10 to outfile.txt.
Can I do the same while I'm viewing a file using
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.Visit Stack Exchange
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
10Gmm1G|mcat > outfile.txt
less) seems to work as long as the input doesn't fit in one screen (in which case all the input ends up in
outfile.txt for some reason).
10Gbrings you to line
gin this case) brings you to line 1
|mpipe from the current line to mark
cat > outfile.txt: that's piped to that command.
10Gbrought me to the 10th line before I could type the rest, but it did indeed work. Feb 17, 2014 at 16:57
You could use
view which is the same as
less-- it is my understanding that
vicauses the whole file to load at once. Feb 17, 2014 at 16:59