Synchronized editing in vim's buffers

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Synchronized editing in vim's buffers

Ven Tadipatri
Hi,
   I was trying to figure out how to edit 2 files in parallel, side by side. This post helped:


  But I have some sort of paging error, where the lines seem to be off, and I'm not sure what's going on. 
I opened two files in vim, then did ctrl+wv followed by :b2 (to get the second buffer)
   I did :set scrollbind in one file, then :set scrollbind in the other one. It looked like that didn't do much, so I tried
:syncbind  and it looked like as a I paged down in one the other file also was "in synch". Well, almost, because
when I was at line 45 in one, I was at line 1 in the other. So as I started paging up and down, one buffer was
always about a page off from the one.
   Clearly there's something I'm not understanding about synching both buffers. How do I use scrollbind and syncbind?
All I want is that if I go to line 100 in one buffer, I'm at line 100 in the other one. Or, what would be nice
is some sort of "toggle", so I could turn the synching on and off.

Is this possible in vim?

Thanks,
Ven

--
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
Reply | Threaded
Open this post in threaded view
|

Re: Synchronized editing in vim's buffers

Benjamin Fritz
On Tuesday, March 27, 2012 1:21:17 PM UTC-5, vtadipatri wrote:

> Hi,
>    I was trying to figure out how to edit 2 files in parallel, side by side. This post helped:</div>
>
> </div>
> <a href="http://stackoverflow.com/questions/4120518/how-do-i-synchronously-view-and-scroll-vertically-split-buffers-in-vim" target="_blank">http://stackoverflow.com/<WBR>questions/4120518/how-do-i-<WBR>synchronously-view-and-scroll-<WBR>vertically-split-buffers-in-<WBR>vim</a></div>
>
>
>
> </div>
>   But I have some sort of paging error, where the lines seem to be off, and I&#39;m not sure what&#39;s going on. </div>
> I opened two files in vim, then did ctrl+wv followed by :b2 (to get the second buffer)</div>
>
>
>    I did :set scrollbind in one file, then :set scrollbind in the other one. It looked like that didn&#39;t do much, so I tried</div>
> :syncbind  and it looked like as a I paged down in one the other file also was &quot;in synch&quot;. Well, almost, because</div>
>
>
> when I was at line 45 in one, I was at line 1 in the other. So as I started paging up and down, one buffer was</div>
> always about a page off from the one.</div>
>    Clearly there&#39;s something I&#39;m not understanding about synching both buffers. How do I use scrollbind and syncbind?</div>
>
>

If you're editing 2 separate files, all you should need to do is set the options, and they will scroll together. However, if you also want the positions to be the same between the two, you'll need to first position them to the same place before setting the options. scrollbind just makes the windows scroll together, so a change in one's position also changes the other's in the same way; it doesn't force them to the same starting position.

> All I want is that if I go to line 100 in one buffer, I&#39;m at line 100 in the other one. Or, what would be nice</div>
> is some sort of &quot;toggle&quot;, so I could turn the synching on and off.</div>
>

Are you saying you also want the cursor position to be the same between the two? Or just the scroll position? The cursor position can also be bound, with 'cursorbind', in recent versions of Vim.

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