Reputation: 55
I'm trying to walk through my buffers list, select a single line from each buffer, and to have them all concatenated into a single file (or other buffer). As in:
file1
... line2 ...
file2
... line2 ...
file3
... line2 ...
and so on.
all into:
myfile
line2 (file1)
line2 (file2)
line2 (file3)
I can't seem to get my registers working, and bufdo is causing me heartache for some reason...
[clarification] I was hoping I could use bufdo to walk through all my buffers, yank the second line from each, and append it into a register.
Then on another file, just paste the register contents into it (containing the second line from all of my buffers).
Upvotes: 4
Views: 1559
Reputation: 497012
You should be able to do this with something like:
bufdo normal 2G"Ayy
which iterates through the buffers and runs the given command in normal mode. 2G
jumps to the appropriate line, and "Ay
yanks into register a, appending instead of overwriting (since the A is capitalized). Make sure register a is empty before you start!
You can use windo
or tabdo
if you have windows or tabs instead of buffers.
Upvotes: 5