4

I know the separate answers. For example,

  • To open several files: :n \**/*.f90
  • To save *.f90 file to HTML: :TOhtml and :wq.

However, I don't know how to combine both of them.

2
  • Do you have a plugin which has a command or function like ,Tohtml?
    – SibiCoder
    Commented Jun 15, 2016 at 5:04
  • 5
    TOhtml is built into Vim. Commented Jun 15, 2016 at 6:24

3 Answers 3

6

After you've added your files to the arguments list with :n ./**/*.f90 (:args + filenames would do the same thing and is perhaps more obvious) you can use:

:argdo exe 'TOhtml' | wq

:argdo will execute its following commands for each buffer that's in the argument list. Note that you need to use TOhtml with :execute since it isn't defined to allow a following |. Using :execute allows you to work around this.

You may wish to modify the :w command to write the generated HTML buffer into another directory (e.g. w html/%). And it's probably a good idea to close each generated window as you go with :q so Vim doesn't run out of room for windows if you have lots of files to process.

1
  • Thanks for your answer. How can we restore the colors of the vim in the html files? Commented Aug 2, 2016 at 21:55
2

I would suggest the following combined command:

:args ./**/*.f90 | argdo execute TOhtml

First, use args to fill the argument list, then use argdo to execute the TOhtml command. There should be no reason to wq, since there is no change to the files, thus I would instead do e.g. :qa when you were finished and happy.

3
  • 1
    The generated file needs writing both because, well, it does, and also because :next will fail if you don't have autowrite set. And if your argument list is large you might run out of room for windows, so it's a good idea to :q as well as :w.
    – Antony
    Commented Jun 15, 2016 at 13:13
  • 2
    Ah, you are right. I didn't look well enough into what TOhtml did. I think you could improve your answer if you included my first :args ... command, though. Commented Jun 16, 2016 at 10:29
  • The OP did that already so I presumed it was unnecessary, but it's definitely worth mentioning that up front since using :args first is quite important; thanks! (I respond eventually :-) )
    – Antony
    Commented Sep 28, 2017 at 9:27
2

As pointed by "Karl Yngve Lervåg" in his comments, combining the answers of both "Karl Yngve Lervåg" and "Antony" gave me the desired result.

So, after opening the first .f90 file, you should use the below command

:args ./**/*.f90 | argdo exe 'TOhtml' | wq

The only trouble which I am still facing with the above method is: generated html files doesn't have colors of vim (except for the first .f90 file).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.