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.
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.
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.
: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
.
TOhtml
did. I think you could improve your answer if you included my first :args ...
command, though.
Commented
Jun 16, 2016 at 10:29
:args
first is quite important; thanks! (I respond eventually :-) )
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).
,Tohtml
?TOhtml
is built into Vim.