I've got a HTML file, and I'd like to grab all the links that are in the file and save it into another file using Vim.
I know that the regex would be something like:
:g/href="\v([a-z_/]+)"/
but I don't know where to go from here.
Jeff Meatball Yang was almost there.
As Sasha wrote if you use w it writes the full original file to the outfile
To only write the matched line, you have to add '.' before 'w':
:g/href="\v([a-z_/]+)"/ .w >> outfile
Note that the outfile needs to exists.
clear reg:x
qxq
search regex
(whatever) and append to reg:x
:g/regex/call setreg('X', matchstr(getline('.'), 'regex') . "\n")
open a new tab
:tabnew outfile
put reg:x
"xp
write file
:w
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With