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.

  • Do you have a plugin which has a command or function like ,Tohtml? – SibiCoder Jun 15 '16 at 5:04
  • 5
    TOhtml is built into Vim. – Karl Yngve Lervåg Jun 15 '16 at 6:24
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.

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.

  • 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 Jun 15 '16 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. – Karl Yngve Lervåg Jun 16 '16 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 Sep 28 '17 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, privacy policy and cookie policy

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