I'm reading through a very large web service log, and I want to pull a single line out from the file, and write it to a new file.
The log lines consist of web service request XML, so they are long and unwieldy.
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityw
can operate on ranges, so you can do:
:.w foo
From :help :w
:
:[range]w[rite]! [++opt] {file}
Write the specified lines to {file}. Overwrite an
existing file.
Any range would do, so the following will write lines N-M inclusive to file foo
:
:N,Mw foo
The .
in the first command stands for the current line. See :help :range
for more information.
:34908,34914w ~/webservicelogextract.txt
:
from Visual mode, it automatically inserts '<,'>
for you. This is a range using special marks that refer to the start and end of a Visual selection. Leave the inserted range and type in your command (it will look like :'<,'>w webservicelogextract.txt
).