vim / vim

The official Vim repository
https://www.vim.org
Vim License
36.48k stars 5.45k forks source link

VIM Editor - TOhtml is not capturing the Character level differences #1725

Open sandosh143 opened 7 years ago

sandosh143 commented 7 years ago

I am using the "diffchar.vim" plugin to get the character level differences between 2 files. In the terminal I am able to see the character differences but when I try to convert that to html using :TOhtml, its not capturing the character differences. Its capturing only the line differences.

Version-Release number of selected component (if applicable): Vim (version: 7.4.629) Operating system/version: CentOS release 6.8 (Final) 2.6.32-642.1.1.el6.centos.plus.x86_64 Terminal name/version: /dev/pts/1 $TERM: xterm

Steps to Reproduce: Install the diffchar.vim plugin and run the below command to compare the two files using "vimdiff" or "vim -d"

vimdiff <file1> <file2> -c :TOhtml -c wqa

Actual results: In the terminal you will be able to see the character level differences but when you convert that to html file its showing the line differences.

line difference

Expected results: Both in the terminal & html we need to see the character level differences.

exact difference

vim-ml commented 7 years ago

Thank for using diffchar.vim. TOhtml takes only syntax highlightings for colors, but diffchar.vim uses matchadd ones. I modified 2html.vim, which is located in $VIMRUNTIME/syntax directory, to handle them in diff mode. Please try it and use the latest diffchar.vim as well.

vim-ml commented 7 years ago

Thank for using diffchar.vim. TOhtml takes only syntax highlightings for colors, but diffchar.vim uses another ones. I modified 2html.vim, localted at $VIMRUNTIME/syntax directory, to handle them. Please try it and use the latest diffchar.vim as well.

vim-ml commented 7 years ago

On Di, 30 Mai 2017, Rick Howe wrote:

Thank for using diffchar.vim. TOhtml takes only syntax highlightings for colors, but diffchar.vim uses matchadd ones. I modified 2html.vim, which is located in $VIMRUNTIME/syntax directory, to handle them in diff mode. Please try it and use the latest diffchar.vim as well.

Note, there is an open issue on the tohtml repository to take match() functions into account: https://bitbucket.org/fritzophrenic/vim-tohtml/issues/9/suggestion-question-option-to-export-to

You might want to contribute your 2html patch there.

Best, Christian -- Vati, was heißt "FORMATIERE LAUFWERK C:?"

sandosh143 commented 7 years ago

Sorry for the stupid question. Do I need to use "diff" command if I need to use "2html.vim"? Please assist.

vim-ml commented 7 years ago

You can simply run TOhtml as you did, after replacing your $VIMRUNTIME/syntax/2html.html with my modified one.

sandosh143 commented 7 years ago

I tried using this modified 2html.vim file but its not working. Getting this error while executing.

$ vim -d old_172.30.78.101 new_172.30.78.101 -c :TOhtml -c wqa 2 files to edit "old_172.30.78.101.html" [New File] Error detected while processing /home/test/.vim/plugin/2html.vim: line 725: E121: Undefined variable: g:loaded_2html_plugin E116: Invalid arguments for function extend Press ENTER or type command to continue

sandosh143 commented 7 years ago

I placed the file in $VIMRUNTIME/syntax/ directory. When i do a TOhtml its highlighting only the first occurance of difference. Its not highlighting the other occurances in the same line. Its just moving to the next line. Can you please help?

kekec14 commented 5 years ago

I am using vim8.1 from vim.org (self installing executable), with latest diffchar.vim plugin. Which 2html.vim i should use to export html in the same format as it is seen in vim. Thank you!

chrisbra commented 5 years ago

I suppose the 2html plugin does not notice that the diffchar.vim plugin was used and highlights the diff differently. I think it doesn't handle the matchadd() functionality yet.

Related 2html issue: https://bitbucket.org/fritzophrenic/vim-tohtml/issues/9/suggestion-question-option-to-export-to

kekec14 commented 5 years ago

Is there any other option to get export of vim diff? It is not necessary to be html.

chrisbra commented 5 years ago

What do you mean with export of vim diff? I think all you can do is share the patch file.

kekec14 commented 5 years ago

I am working on a script, which uses vim diff to compare two csv files. I want to get result of vim diff written in file, as for example:TOhtml. But with :TOhtml I can’t get the same output as it is seen directly in vim (with diffchar plugin). Now I am asking if there is any other option to get identical output as in vim directly.

What do you mean by sharing patch file?

Thank you!

chrisbra commented 5 years ago

git diff --no-index plus e.g. using diff-highlight from git. Please ask user questions on the vim_use mailinglist or use vi.stackexchange.com. This here is a bug tracker for problems with Vim. We cannot provide individual help here

fritzophrenic commented 1 year ago

No new status on this, but the migrated issue tracker for adding matchadd() tohtml is here: https://sourceforge.net/p/vim-tohtml/issues/9/

That does seem like something I'll want to prioritize for new features after I get bugfixes completed.