Wednesday, August 5, 2020

Re: scroll by screen line ?

On Wed, Aug 5, 2020 at 5:53 AM mckel...@gmail.com <mckelly2833@gmail.com> wrote:
>
> Hi,
>
> Is it possible to scroll like <C-e> but have it be virtual/screen line and not whole line ?
> I want to have wrap on, but also want to scroll by screen line when I have long lines.
> Does anyone know if that is possible ?
> Sort of like: j -> gj ; <C-e> -> ???
> I suppose I could do the math in a function and go to bottom of screen and gj X times then go back to previous line, col - but does anyone know of a better way ?
>
> thanks for everything vim,
> -m

I don't think it is, because the first character at the top of a Vim
window is either the first character of a (file) line, or some
character in a line which is too long for the window. So unless the
current line is too long for the window, Ctrl-Y will show one more
full file line at the top of the window, and Ctrl-E will make one full
file line disappear at the top of the window. Similarly, scrolling by
mouse will always make an integer number of file lines appear or
disappear at the top (again unless the current line is too long for
the window). I believe that this is as much part of the philosophy of
Vim as the fact that all displayable Latin, Greek, Cyrillic, Hebrew,
etc. characters (other than tabs) always occupy exactly the same
amount of height and width no matter the character in all the windows
of a single instance of Vim, including gvim and macvim, and that a
single fullwidth CJK character (no matter which one) always takes up
exactly twice as much space as two "narrow" characters (e.g. Latin,
etc. characters), except that if there is only one character-width
left at the end of a screen line (with 'wrap' on) it will be thrown
off to the next screen line.

AFAIK, to make sure than Vim always scrolls only a single screen line
at a time you would need to set 'nowrap' but of course any line longer
than 'columns' would then be only partly displayed. Me too, I prefer
'wrap' being on except in (g)vimdiff, and sometimes I am surprised
when going to the next line at bottom makes the display jump up by
several lines because a long line has disappeared at top, but I
believe that "Vim is like that".

Oh, there _is_ a possibility (of sorts): by setting 'lines' to 1 (plus
1 for the status line plus 'cmdheight' for the command-line area) you
could always wrap by screen lines, but OTOH it would nullify the
advantage of ":set wrap" so I don't think you would like it. :-P

Best regards,
Tony.

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CAJkCKXt-0vcG4XaBV4Rw7W3cnFb9mivL8t%2B1J_j2Zj38d3duCQ%40mail.gmail.com.

No comments: