On 03/12/2012 05:28 AM, Gary Johnson wrote:
On 2012-03-11, powertomato wrote:
Hi,
I'm using vim in a script to generate syntax highlighted HTML files
for source code. A very simple one to reproduce my error is:
#!/bin/bash
if [ $# -ne 2 ];then
echo 'Usage:'
echo " $0 /path/to/src /path/to/file.html"
else
vim -n $1 -cTOhtml -c"w! $2" -cq! -cq!&>/dev/null
fi
and for the sake of completenes here is the .vimrc of the user running it:
let html_use_css=1
let html_number_lines=1
let html_no_pre=1
syntax on
What I'm doing is:
* open a file (vim -n $1)
* generate syntax-highlighted HTML (-cTOhtml)
* save it somewhere (-c"w! $2")
* and quit both windows (-cq! -cq!)
While this works well I'm not quite happy with it. After adding
"&>/dev/null" (I also tried using @vim [...]) to suppress the output
the script takes ~3 seconds per file, idling most of the time. I
think this is because of the ncurses library which isn't satisfied
with /dev/null not beeing a terminal.
Is there a way to get around this (e.g. running vim quietly just
processing through some commands or using some settings to ignore the
case of /dev/null not beeing a terminal)?
Use the -E and -s options, e.g.,
vim -E -s -n $1 -cTOhtml -c"w! $2" -cq! -cq!
See
:help -E
:help -s
Regards,
Gary
I came across those options, but it didn't work. Now you mentioned it
should, I tried using them again. It turned out that -E isn't happy with
-cTOhtml and vim also ignores the .vimrc when in exim mode so I had to
run "2html.vim" directly and add the .vimrc options to the call. If
someone is interested here is the working version of the call:
vim -nEs $1 +"syn on" \
+"let html_no_progress=1" \
+"let html_use_css=1" \
+"let html_number_lines=1" \
+"run! syntax/2html.vim" \
+"w! $2" \
+"q!" \
+"q!" &>/dev/null
Thanks a lot!
Best regards,
Stefan
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php