Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work
On Fri, Feb 23, 2018 at 9:43 AM, Igor Forcawrote: > @Arun, I have tested your code in deep. It is working perfectly. What I > have found is little trouble in the case when first line include the change. > > File1: > aaa ccc > aaa ccc > > File2: > aaa bbb > aaa bbb > > If cursor is in file1 at first line first column, diff enabled and > pressing ]x I expect cursor to jump to first line first c letter, but it > jumps to second line first c character. It looks this problem only appears > if difference is in first line. If difference is any other line but first > one the problem does not appear. > > That is expected, the script searches by going down a line first, so hits on the current line will be missed. Optimizing for that case was not worth the changes it introduced. As for the difference between the mappings ]c and ]x, the former goes over all diff context (addition, deletion), where as the latter would only look for DiffChanges. If your diff buffer does not have any additions or deletions, both would behave the same. 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work
Le vendredi 23 février 2018 18:43:35 UTC+1, Igor Forca a écrit : > @Arun, I have tested your code in deep. It is working perfectly. What I have > found is little trouble in the case when first line include the change. > > File1: > aaa ccc > aaa ccc > > File2: > aaa bbb > aaa bbb > > If cursor is in file1 at first line first column, diff enabled and pressing > ]x I expect cursor to jump to first line first c letter, but it jumps to > second line first c character. It looks this problem only appears if > difference is in first line. If difference is any other line but first one > the problem does not appear. > > @Rick, thanks for providing the info about diffchar plugin. I tested it and > it is awesome. I will definitely use it for projects when I work with code. > But for projects where I analyze huge data files like long lines and 3000+ > rows, this plugin is understandably little bit slow. Thanks. Windows' like F3 key : nnoremap? ']c':'' nnoremap ? '[c':'' works fine and similar to Windows search. -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work
@Arun, I have tested your code in deep. It is working perfectly. What I have found is little trouble in the case when first line include the change. File1: aaa ccc aaa ccc File2: aaa bbb aaa bbb If cursor is in file1 at first line first column, diff enabled and pressing ]x I expect cursor to jump to first line first c letter, but it jumps to second line first c character. It looks this problem only appears if difference is in first line. If difference is any other line but first one the problem does not appear. @Rick, thanks for providing the info about diffchar plugin. I tested it and it is awesome. I will definitely use it for projects when I work with code. But for projects where I analyze huge data files like long lines and 3000+ rows, this plugin is understandably little bit slow. Thanks. -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work
I am not sure how my plugin, https://github.com/rickhowe/diffchar.vim, can help you, but it provides ]b/[b/]e/[e keymaps to jump cursor around the exact differences. Please try it. -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work
@Arun, thanks a million for this script. ]x and [x work exactly what I want. I also tested the ]c and it behaves the sames as ]x and [c behaves the same as [x on my previous post samples. I actually only need ]x and [x behavior, but just out of curiosity what suppose to be the difference between "x" and "c" commands? P.S. Just two small typos in your script. Comments in lines 47 and 49 are the same as lines 52 and 54. Probably copy/paste problem. -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
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, Arunwrote: > On Wed, Feb 21, 2018 at 10:53 PM, Igor Forca 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. diff_search.vim Description: Binary data
Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work
On Wed, Feb 21, 2018 at 10:53 PM, Igor Forcawrote: > @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. > > > -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work
@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. 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. -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work
On Wed, Feb 21, 2018 at 5:27 AM, Igor Forcawrote: > @Christian, thanks a lot for explanation. It looks like ]c jumps through > lines and searches for changes (it skips the same lines in both files), but > cursor is always placed on first character in line. Interesting. It looks I > misunderstood the help: > ]c Jump forwards to the next start of a change. > > Is there some solution to jump to the first character of change. So in the > case of my sample (step 2 in my previous post) to first letter of b? > Imagine I have file with long lines (I receive data from database with > multiple columns) and jumping to the first character colored red would > spare me plenty of time. Using the same shortcut to jump to next block of > changes etc. Does anything like that exists? > > Here is a script-ized way: -- 8< -- fu! s:DiffSearch(opt) let ctx = synIDattr(diff_hlID(line('.'), col('.')), "name") let skip_same = 1 if a:opt != 'curline' norm! ]c endif let cur_pos = getpos('.') for i in range(1, col('$')) let cur_ctx = synIDattr(diff_hlID(line('.'), i), "name") if skip_same && ctx == cur_ctx continue endif let skip_same = 0 if cur_ctx == "DiffText" let cur_pos[2] = i call setpos('.', cur_pos) break endif endfor endf nn ]c :call DiffSearch('') nn ]x :call DiffSearch('curline') -- 8< -- Use ]c for the behavior you want, and use "]x" if you want to search in the current line. Feel free to modify this to suit to your needs. Once search pattern \%h or \%s (help todo.txt) gets implemented in vim, you should be able to just search for "DiffText" directly. 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work
@Christian, thanks a lot for explanation. It looks like ]c jumps through lines and searches for changes (it skips the same lines in both files), but cursor is always placed on first character in line. Interesting. It looks I misunderstood the help: ]c Jump forwards to the next start of a change. Is there some solution to jump to the first character of change. So in the case of my sample (step 2 in my previous post) to first letter of b? Imagine I have file with long lines (I receive data from database with multiple columns) and jumping to the first character colored red would spare me plenty of time. Using the same shortcut to jump to next block of changes etc. Does anything like that exists? -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work
On Mi, 21 Feb 2018, Igor Forca wrote: > @ZyX, I tested: > 1. c is ASCII character also ]c can be typed in. I actually do not need > mapping, I would just like to get ]c working. I did the mapping just to test > if > something is wrong with the keyboard. > > 2. Just to make a simple test I created two files with content. > a) create files > file1: > aaa bbb > > file2: > aaa ccc > > b) open Vim with: gvim -u NONE -N > c) :e file1 > d) :vert diffsp file2 > e) ]c --> it does nothing. I expect cursor jumps to first letter of bbb. Add a leading newline on both files first. Put you cursor on the first line and type ]c. You will note, the cursor jumps to the beginning of line 2. It there are no further differences, the command does nothing and beeps I think. Note, it won't jump to the b/c part, e.g. to the char that is actually different Best, Christian -- Ein deutsches Wort mit 6 'TZ': Mortzatzventzkrantzkertzenglantz. -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work
@ZyX, I tested: 1. c is ASCII character also ]c can be typed in. I actually do not need mapping, I would just like to get ]c working. I did the mapping just to test if something is wrong with the keyboard. 2. Just to make a simple test I created two files with content. a) create files file1: aaa bbb file2: aaa ccc b) open Vim with: gvim -u NONE -N c) :e file1 d) :vert diffsp file2 e) ]c --> it does nothing. I expect cursor jumps to first letter of bbb. 3. Other diff commands work fine. Like :diffget and :diffput I use all the time without a problem. Additionally: It may not be a Windows problem. Now I did a test on Ubuntu 16.04 Server. I did the test from step 2 above and the same problem. Strange... Do I understand correctly what ]c should do? As I understand the CURSOR should jump to the first letter of bbb string. Is it? -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work
2018-02-21 12:43 GMT+03:00 Igor Forca: > @ZyX, I did: > 1. Start-up Vim in clean: > gvim -u NONE -N > > 2. Open the first file: > :e file1.txt > > 3. Diff mode second file: > :vert diffsp file2.txt > > 4. Do the mapping you suggested: > nnoremap a ]c > > 5. Press the a key and nothing happens. > > So still a problem. > > By the way if mappings would be the problem then ]c shortcut should be > working out of the box because I have run gVim in: "gvim -u NONE -N" clean > environment. (Environment would be clean with `-i NONE` as well. But it should not matter here, I know no way for viminfo file to define a mapping.) > > Any other idea? Some other ideas: 1. Check whether `c` is an ASCII `c` by using `ga` with cursor over it (first typing that in some file, of course). Same for `]`. If keyboard is actually a problem then typing `]c` when defining mapping is just as good as just typing `]c`. Though I do not see any problems in your email. 2. Based on my observations a “change” is “block of changed lines not interleaved with non-changed lines”. E.g. when I did `vimdiff` on README.md and CMakeLists.txt from Neovim repository I saw that Vim registered only two changes there: first line (README)/first two lines (CMakeLists.txt) and everything else (the only non-changed line in this case was a blank second (README)/third (CMakeLists) line). In the example `]c` is only capable of jumping from the first few lines and from nowhere else. Also `]c` will not bring you to the first change if current change is the last one: it does not wrap. This problem should be immediately visible though. 3. Check what other diff command do in your case. Specifically, what `:diffget` changes, maybe it will yield some hints. Also AFAIK Windows may have some problems with diff.exe availability, but it is supposed to be shipped with Vim and you would definitely see the problem just after `:diffsplit` if that was the case. > > -- > -- > 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+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work
@ZyX, I did: 1. Start-up Vim in clean: gvim -u NONE -N 2. Open the first file: :e file1.txt 3. Diff mode second file: :vert diffsp file2.txt 4. Do the mapping you suggested: nnoremap a ]c 5. Press the a key and nothing happens. So still a problem. By the way if mappings would be the problem then ]c shortcut should be working out of the box because I have run gVim in: "gvim -u NONE -N" clean environment. Any other idea? -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: vimdiff - how to jump to next difference in long line - shortcut ]c does not work
2018-02-21 11:45 GMT+03:00 Igor Forca: > Hi, > I have files with long lines and when doing diff it is time consuming to move > to the diff change (marked red in vimdiff). > > I have searched the help: > :h jumpto-diffs > > With explanation that: > ]c > should jump to the next start of the change. > > But in my case this key shortcut does nothing. > > I started gVim on Windows 7 with command: > gvim -u NONE -N > and key shortcut still does not work. > > Maybe this is related to my keyboard (Slovenian keyboard): > See keyboard layout: https://gate2home.com/Slovenian-Keyboard > I have to press to get ] key. > > Any idea what is wrong? Any workaroud? > I tried to use mapping like: > :map a ]c > and when pressing a nothing happens. You should not be ever using `map` unless you can say “I need a mapping in select mode because … and I need my mapping trigger other mappings because …”. `]c` may not work not because of keyboard, but *because of mappings*. Use `nnoremap` to check; `nnoremap`, `xnoremap` and `onoremap` when defining actual mapping for other modes. > > My gVim is v8.0.1529 witch is latest nightly build for win32 from: > https://github.com/vim/vim-win32-installer/releases/download/v8.0.1529/gvim_8.0.1529_x64.zip > > -- > -- > 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+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
vimdiff - how to jump to next difference in long line - shortcut ]c does not work
Hi, I have files with long lines and when doing diff it is time consuming to move to the diff change (marked red in vimdiff). I have searched the help: :h jumpto-diffs With explanation that: ]c should jump to the next start of the change. But in my case this key shortcut does nothing. I started gVim on Windows 7 with command: gvim -u NONE -N and key shortcut still does not work. Maybe this is related to my keyboard (Slovenian keyboard): See keyboard layout: https://gate2home.com/Slovenian-Keyboard I have to press to get ] key. Any idea what is wrong? Any workaroud? I tried to use mapping like: :map a ]c and when pressing a nothing happens. My gVim is v8.0.1529 witch is latest nightly build for win32 from: https://github.com/vim/vim-win32-installer/releases/download/v8.0.1529/gvim_8.0.1529_x64.zip -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.