Thursday, February 22, 2018

Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work

On Thu, Feb 22, 2018 at 9:26 AM, Arun <aemails@gmail.com> wrote:
On Wed, Feb 21, 2018 at 10:53 PM, Igor Forca <igor2x@gmail.com> wrote:
@Arun, thanks a lot for this code. I have performed two tests:

TEST 1: LINES WITH NO DIFFERENCE BETWEEN TWO LINES WITH DIFFERENCES

File1:
aaa aaa
aaa bbb
aaa aaa
aaa bbb

File2:
aaa aaa
aaa ccc
aaa aaa
aaa ccc

Lines 2 and 4 are different. There are lines without difference between two different lines, like line 3. In this case ]c works perfectly it jumps between diff changes. Excellent.


TEST 2: LINES WITH DIFFERENCES ARE ONE AFTER ANOTHER

File1 - the same as in test 1.
File 2:
aaa aaa
aaa ccc
aaa ccc
aaa ccc

Now lines 2, 3 and 4 are different. Cursor on first line first column and pressing ]c jumps correctly to second line at first letter of c. Now I see this difference is acceptable and I would like to jump to next difference. Executing ]c I expect to get to the next (third) row and search for difference. Like executing j0 (down and at first character in line) and then executing ]c again.

That is the native behavior of ]c, it skips over current diff context. Working around in the script will be messy, will look into it when I can.

Regards,
-Arun
 

I would like to have ]c working just like search does. For example searching for aaa, executing /aaa then n (for next). Every time I press n it gets to the next search string. Like that I would like to have ]c to "search" next difference. Difference should not be the block but line.

P.S. I am sorry I am not familiar with vim scripting. I would do the change myself if I know how to program in vim-script.



Give the attached script a shot. Try the "]x" mapping as well, it sounds like what you are after.

Regards,
-Arun

--
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment