3

Using vimdiff, I can compare two files and generate it's corresponding HTML via the following command:

: TOhtml | wq | q | q

(the wq will save the Diff.html file, and the two qs will quit out of the two vimdiffing files.)

Before I output to the Diff.html file, I'd like for all of the folds (places where code is identical between files) to be expanded.

I'm trying to run a command in Vim, like so:

:normal zo | TOhtml | wq | q | q

However, the result is not what I expected. The above multi-command will only expand the folds (via zo); that is, it will ignore TOhtml, wq, q, and q. I have to use the normal command because zo is a normal-mode command, as opposed to a execute-mode command. It seems that when chaining commands after the normal command, the latter commands will not execute.

Edit: Although it appears you cannot have execute commands after a normal command, you can have a normal command after an execute command. For example:

:q | normal zo

will in fact quit out of the first file's diff and then expand all folds in the remaining file's diff.

4

From :help :normal:

This command cannot be followed by another command,
since any '|' is considered part of the command.

You can get around this by using :execute:

:exe 'normal! zo' | TOhtml | wq | q | q

But perhaps it is better to make a function/command:

fun! DiffHTML()
    normal! zo
    TOhtml
    wq | q | q
endfun

command! DiffHTML call DiffHTML

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.