cat file | vim -

What stands the "-" for?

It is a standard *nix convention of accepting stdin as the source for the file (in this case, the output of cat). That way, we never actually bung with the original file. If you don't care if it gets hosed in the process, you can just do

        vim file.txt

Then, clean up the stuff we don't want

    1,/received/d
    $?^\s*For subscribe options?,$d

to strip off the header and footer.

this worked out nicely

Glad to hear...

My first-pass solution will end up with duplicate results if
  more than one of your keywords appear in the same "block"
but on diff. lines:

    :let @a=''
    :g/red\|relativistic/?^\s*astro-ph?,/^\s*astro-ph/-y A
    :%d
    :put a
    :1d
    :wq name_of_output.txt

this is the content of foo.vim? On separated lines? I also tried with
CTRL + V + ENTER at the end of each line, but the result was the
same...

foo.vim consists of all 8 lines...first the two that "worked out nicely" to strip the header and footer, followed by the 6 lines in question here. In the foo.vim file, you'd omit the leading colons (I don't think there's any harm in having them in there, but their absense makes it easier to read), and there's no need for extra ^M entries in the file with ^V, as the newlines are already in the file

    cat input.txt | vim -s foo.vim -

when I run it I end up with an empty file... ?

Well, you should be able to trace through it by entering each of the commands individually instead of sourcing the file to see where things are going funky. Places matters could go awry:

Prob: the :g command isn't finding anything
Check: do ":echo @a" after the ":g" command to ensure that you've got some data

Prob:  @a has data, but it's not getting pasted
Check: that you're doing the ":put"

Prob:  No file named "name_of_output.txt" is being created
Check: that you have write permissions in the intended target
Check: that the file "name_of_output.txt" doesn't already exist
Check: that you're actually looking at the contents of the output file (name_of_output.txt) rather than the input file

Just a few more ideas...

I was saying in my deleted email that in any case it's a nice
lesson... When I think that people here think I know vim... what a
shame!

Well, we all have our peculiar areas of specialty. When it comes to things like plugins, syntax-highlighting nuances, i18n/encoding stuff, and indentation, I leave that to the folks on the list that are far more well-versed than myself. I'm more of an "ex" & regexp sorta guy, doing some crazy stuff there, but otherwise, just using pretty stock unadorned vim.

-tim




Reply via email to