Vimdiff counting dark blue lines

67 views
Skip to first unread message

K otgc

unread,
Sep 30, 2025, 12:43:47 PMSep 30
to vim_use
Hello,
would there be a command to count the dark blue lines on the vimdiff Bookmarks1 and Bookmarks2 please?

Once I figured out how many extra lines there are, I can then work on some type of merge.

At the bottom of the vimdiff Bookmarks1 and Bookmarks2, there's some information showing:
Bookmarks1  4675,1  Bot and Bookmarks2  4655,1  Bot
I guess this means Bookmarks1 has 20 more lines thank Bookmark2.
However this isn't much help.
What I really need is Bookmarks1 has these dark blue lines for lines of data which isn't in Bookmarks2.
Vice versa too.

Then the fun bit merging or manually diffget and diffput each and every single line, which might be out of the question if too many.

Many thanks for any suggestions.

K otgc

unread,
Oct 2, 2025, 3:19:07 AMOct 2
to vim_use
The dark blue lines would be unique added lines.screenshot_20251002_091657.png

K otgc

unread,
Oct 3, 2025, 7:07:37 AMOct 3
to vim_use
So not simply adding numbers to lines/rows, but totalling the unique added lines on the left and the right windows.

Yee Cheng Chin

unread,
Oct 5, 2025, 2:54:15 AMOct 5
to vim...@googlegroups.com
I'm imagining your diffopt does not have "inline:char" or "inline:word" right? In this case, the "dark blue lines" are basically "added lines" that are just the number of lines on the left minus the number of lines on the right. You just need to subtract them.

In order to count number of added/changed lines, you need some way of querying them using Vimscript, and currently Vim has pretty limited APIs for querying the diff structures. The one that you may want to use is `diff_hlID`. For example you can use diff_hlID(4321, 1)->synIDattr("name") and check if it's non-empty and count the lines between two sides. It requires a bit of scripting to work. There isn't a simple command to count this. I think it's more helpful if you explain exactly why you need to count these lines to begin with though.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/4302280d-2e8f-45d9-bcda-7b0f7100490en%40googlegroups.com.

K otgc

unread,
Oct 6, 2025, 5:26:19 AMOct 6
to vim_use
'Tis not so simple as sideX minus sideY.
Out of screenshot, Bookmarks1 indeed has unique added lines that Bookmarks2 doesn't have.
However Bookmarks2 also has unique added lines that Bookmarks1 doesn't have.

I solved this 3 ways:
1:
manual count

2.
$ diff Bookmarks1 Bookmarks2 | grep '^<' | wc -l 42 $ diff Bookmarks1 Bookmarks2 | grep '^>' | wc -l 22

3.
$ diff <(sed '1,2d' Bookmarks1) <(sed '1,2d' Bookmarks2) | grep '^>' | wc -l 21 $ diff <(sed '1,2d' Bookmarks1) <(sed '1,2d' Bookmarks2) | grep '^<' | wc -l 41

Ben Yip

unread,
Oct 8, 2025, 2:24:46 AMOct 8
to vim...@googlegroups.com
`git diff --numstat A B` is a bit easier.

Yee Cheng Chin

unread,
Oct 11, 2025, 5:25:03 AMOct 11
to vim...@googlegroups.com
What is a "unique" line in your example? All the lines in each diff block are different. That's why they are in the diff to begin with. The "dark blue" lines are just the lines that are extra compared to the other side in this example. Vim doesn't by default do line similarity tests, and it doesn't know that "Bookmarks" and "Bookmarks Toolbar" are similar lines. Maybe I don't understand what you are asking here.

Note: I said Vim doesn't do line similarity tests by default because if you do "diffopt+=linematch:100" it does do that but I don't think you are using that.

Reply all
Reply to author
Forward
0 new messages