On 16/01/09 15:24, Milan Vancura wrote: > Hi all, > > as modern LCDs are wider than it is needed for a usual text editing, a > colleague of mine made the following function to show the file in two windows > beside, to see more lines of a file. 'scrollbind' is used to keep both windows > synchronized (windows have an offset of a window height): > > :e some_file_longer_than_window > :function SplitAndJoin() > :vsplit > :wincmd l > :normal L > :normal z+ > :wincmd h > :windo set scrollbind > :windo set number > :endfunction > :call SplitAndJoin() > > While using this for a while, we found some caveats. One of them is that > commands changing the number of lines (inserting more than one line, lines > deletition etc.) don't update the second window. The workaround is to move a > text in a window then, the easiest way is to press CTRL-Y or CTRL-E. > example: > press "d4k" in the left window - lines disappear but right window > isn't synchronized (only line numbers are). > continue with typing CTRL-E : text in the left window moves off by one > line > and right window synchronizes. > > The expected behaviour is that other window with 'scrollbind' set are > synchronized automaticaly every time the number of lines between windows > changes.
'scrollbind' was originally meant for parallel views of different but related files (e.g. for use in vimdiff), not for different views of a single file. When you delete a line in one file, it doesn't change the number of lines' difference between that file and the other, since it is assumed that you want to look at the _same_ point in _different_ files, not the opposite. To correct sync errors, you can also use (in gvim which has scrollbars and reacts to the mouse) the scrollbar of the non-current window. > > The second problem are wrapped lines - they take space for several screen > lines > so the synchronization of windows is broken than (the offset is wrong, there > are some lines between windows which you can't see). Easy to solve; set 'nowrap'. Or content yourself with an approximate offset, not having one window start exactly where the other one left off and not a single line higher or lower; > > So my idea is to solve both issues at once: make a new suboption to scrollopt: > offsettype. With values "top-top" and "bottom-top" according to lines which > you > want to count an offset of. "top-top" will be used in cases like vimdiff > (top-top offset 0) and bottom-top in case of continuous windows (bottom-top > offset 0). > > I must say I tried to find a fix myself, but unsuccessful. I even can't > understand why pressing CTRL-E help with windows synchronization, there is > nothing about scrollbind in functions handling CTRL-E... > Can anyone help, please? > > Milan > -- The sig separator should be two dashes PLUS ONE SPACE. > Milan Vancura, Prague, Czech Republic, Europe Best regards, Tony. -- ... But if we laugh with derision, we will never understand. Human intellectual capacity has not altered for thousands of years so far as we can tell. If intelligent people invested intense energy in issues that now seem foolish to us, then the failure lies in our understanding of their world, not in their distorted perceptions. Even the standard example of ancient nonsense -- the debate about angels on pinheads -- makes sense once you realize that theologians were not discussing whether five or eighteen would fit, but whether a pin could house a finite or an infinite number. -- S. J. Gould, "Wide Hats and Narrow Minds" --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---