Discussion:
How to make mouse scroll 3 'screen lines'?
ccbrighty .
2008-08-09 20:15:13 UTC
Permalink
Hi Vimmers!
I always need to read texts containing very long lines.
I have 'set wrap' in my .vimrc. then the long lines became a "paragraph",
which
is easy to read(vim do not have a horizontal scroll bar?). But when I use my
mouse to scroll,
it seems that it scrolls 3 'file' lines, not 3 'screen' lines. This is very
unpleasant.
How to set vim to make it scroll 3 'screen' lines, like the scroll work
gedit or Emacs?

A extreme condition: When a file contains only a line, but the line is so
long that when wrapped,
it can not displayed in a screen. Then in the default setting, <C-d>, <C-u>,
scroll bar,
and mouse-scroll all fail to work.

I think we mostly use <C-d> <C-u> and scroll bar to explore file, so they
should care about
screen line instead of file line. Is this a bug of Vim?

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
.幻想之诚
2008-08-10 12:56:25 UTC
Permalink
Hi Vimmers!
I always need to read texts containing very long lines.
I have 'set wrap' in my .vimrc. then the long lines became a "paragraph",
which
is easy to read(vim do not have a horizontal scroll bar?). But when I use my
mouse to scroll,
it seems that it scrolls 3 'file' lines, not 3 'screen' lines. This is very
unpleasant.
How to set vim to make it scroll 3 'screen' lines, like the scroll work
gedit or Emacs?

A extreme condition: When a file contains only a line, but the line is so
long that when wrapped,
it can not displayed in a screen. Then in the default setting, <C-d>, <C-u>,
scroll bar,
and mouse-scroll all fail to work.

I think we mostly use <C-d> <C-u> and scroll bar to explore file, so they
should care about
screen line instead of file line. Is this a bug of Vim?

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Tim Harper
2008-08-10 22:38:17 UTC
Permalink
I too am a bit bothered by this, but not enough to have made a request
on the mailing list :)

Gary and Christian helped me find this one to make lines display if
they won't fit on the whole page:

:set display=lastline

Tim
Post by ccbrighty .
Hi Vimmers!
I always need to read texts containing very long lines.
I have 'set wrap' in my .vimrc. then the long lines became a
"paragraph", which
is easy to read(vim do not have a horizontal scroll bar?). But when
I use my mouse to scroll,
it seems that it scrolls 3 'file' lines, not 3 'screen' lines. This
is very unpleasant.
How to set vim to make it scroll 3 'screen' lines, like the scroll
work gedit or Emacs?
A extreme condition: When a file contains only a line, but the line
is so long that when wrapped,
it can not displayed in a screen. Then in the default setting, <C-
d>, <C-u>, scroll bar,
and mouse-scroll all fail to work.
I think we mostly use <C-d> <C-u> and scroll bar to explore file, so
they should care about
screen line instead of file line. Is this a bug of Vim?
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Tony Mechelynck
2008-08-10 23:52:14 UTC
Permalink
Post by Tim Harper
Post by ccbrighty .
Hi Vimmers!
I always need to read texts containing very long lines.
I have 'set wrap' in my .vimrc. then the long lines became a
"paragraph", which
is easy to read(vim do not have a horizontal scroll bar?). But when
I use my mouse to scroll,
it seems that it scrolls 3 'file' lines, not 3 'screen' lines. This
is very unpleasant.
How to set vim to make it scroll 3 'screen' lines, like the scroll
work gedit or Emacs?
A extreme condition: When a file contains only a line, but the line
is so long that when wrapped,
it can not displayed in a screen. Then in the default setting,<C-
d>,<C-u>, scroll bar,
and mouse-scroll all fail to work.
I think we mostly use<C-d> <C-u> and scroll bar to explore file, so
they should care about
screen line instead of file line. Is this a bug of Vim?
I too am a bit bothered by this, but not enough to have made a request
on the mailing list :)
Gary and Christian helped me find this one to make lines display if
:set display=lastline
Tim
Sure, but that isn't what 幻想之诚 asked for. Well, if you (幻想之诚)
can find a scroll command which acts by screen lines (I didn't, but I
didn't search the help really in detail), just use that as the {rhs} of
a mapping (four mappings actually: two ":map"s and two ":imap"s) with
<MouseUp> and<MouseDown> as the {lhs}.
Best regards,
Tony.
P.S. To use the mouse to move the cursor while keeping it near the
middle of the window if possible:

set wrap display=lastline scrolloff=99999
if has('mouse')
noremap <UpMouse> k
inoremap <UpMouse> <C-O>k
noremap <DownMouse> j
inoremap <DownMouse> <C-O>j
endif

Add a count before the j's and k's if you want the mouse to move the
cursor faster (but perhaps more jerkily).

I'm intentionally reversing the scroll direction because what I'm making
the mouse move is the cursor, not the text. Switch the {lhs} around if
it doesn't feel natural this way.

However, the cursor will still stray away from the middle line when near
the top or bottom of the file, or when on a long wrapped line.


Best regards,
Tony.
--
Q: Why do mountain climbers rope themselves together?
A: To prevent the sensible ones from going home.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
.幻想之诚
2008-08-11 14:56:29 UTC
Permalink
Well, I've tried these ways already, but I found them ungraceful.
(I often need to read texts containing very long lines, for example, some
Chinese TXT ebook.)
I want to find some options to make scroll-bars, <C-d>, <MouseDown>... work
more friendly.
If there is no solution, can someone help me to suggest VIM developers to do
some patches?
I think this function is very essential to a TEXT EDITOR.
Thanks!!

On Mon, Aug 11, 2008 at 7:52 AM, Tony Mechelynck <
Post by Tony Mechelynck
Post by Tim Harper
Post by ccbrighty .
Hi Vimmers!
I always need to read texts containing very long lines.
I have 'set wrap' in my .vimrc. then the long lines became a
"paragraph", which
is easy to read(vim do not have a horizontal scroll bar?). But when
I use my mouse to scroll,
it seems that it scrolls 3 'file' lines, not 3 'screen' lines. This
is very unpleasant.
How to set vim to make it scroll 3 'screen' lines, like the scroll
work gedit or Emacs?
A extreme condition: When a file contains only a line, but the line
is so long that when wrapped,
it can not displayed in a screen. Then in the default setting,<C-
d>,<C-u>, scroll bar,
and mouse-scroll all fail to work.
I think we mostly use<C-d> <C-u> and scroll bar to explore file, so
they should care about
screen line instead of file line. Is this a bug of Vim?
I too am a bit bothered by this, but not enough to have made a request
on the mailing list :)
Gary and Christian helped me find this one to make lines display if
:set display=lastline
Tim
Sure, but that isn't what 幻想之诚 asked for. Well, if you (幻想之诚)
can find a scroll command which acts by screen lines (I didn't, but I
didn't search the help really in detail), just use that as the {rhs} of
a mapping (four mappings actually: two ":map"s and two ":imap"s) with
<MouseUp> and<MouseDown> as the {lhs}.
Best regards,
Tony.
P.S. To use the mouse to move the cursor while keeping it near the
set wrap display=lastline scrolloff=99999
if has('mouse')
noremap <UpMouse> k
inoremap <UpMouse> <C-O>k
noremap <DownMouse> j
inoremap <DownMouse> <C-O>j
endif
Add a count before the j's and k's if you want the mouse to move the
cursor faster (but perhaps more jerkily).
I'm intentionally reversing the scroll direction because what I'm making
the mouse move is the cursor, not the text. Switch the {lhs} around if
it doesn't feel natural this way.
However, the cursor will still stray away from the middle line when near
the top or bottom of the file, or when on a long wrapped line.
Best regards,
Tony.
--
Q: Why do mountain climbers rope themselves together?
A: To prevent the sensible ones from going home.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Tony Mechelynck
2008-08-10 23:31:12 UTC
Permalink
Post by Tim Harper
Post by ccbrighty .
Hi Vimmers!
I always need to read texts containing very long lines.
I have 'set wrap' in my .vimrc. then the long lines became a
"paragraph", which
is easy to read(vim do not have a horizontal scroll bar?). But when
I use my mouse to scroll,
it seems that it scrolls 3 'file' lines, not 3 'screen' lines. This
is very unpleasant.
How to set vim to make it scroll 3 'screen' lines, like the scroll
work gedit or Emacs?
A extreme condition: When a file contains only a line, but the line
is so long that when wrapped,
it can not displayed in a screen. Then in the default setting,<C-
d>,<C-u>, scroll bar,
and mouse-scroll all fail to work.
I think we mostly use<C-d> <C-u> and scroll bar to explore file, so
they should care about
screen line instead of file line. Is this a bug of Vim?
I too am a bit bothered by this, but not enough to have made a request
on the mailing list :)
Gary and Christian helped me find this one to make lines display if
:set display=lastline
Tim
Sure, but that isn't what 幻想之诚 asked for. Well, if you (幻想之诚)
can find a scroll command which acts by screen lines (I didn't, but I
didn't search the help really in detail), just use that as the {rhs} of
a mapping (four mappings actually: two ":map"s and two ":imap"s) with
<MouseUp> and <MouseDown> as the {lhs}.


Best regards,
Tony.
--
On Monday mornings I am dedicated to the proposition that all men are
created jerks.
-- Avery

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Ben Schmidt
2008-08-11 11:57:01 UTC
Permalink
Post by Tim Harper
Post by ccbrighty .
A extreme condition: When a file contains only a line, but the line
is so long that when wrapped, it can not displayed in a screen. Then
in the default setting,<C-d>,<C-u>, scroll bar, and mouse-scroll all
fail to work.
Wow. I wouldn't have expected complete lack of functionality. That
probably is a bug.
Post by Tim Harper
Post by ccbrighty .
I think we mostly use<C-d> <C-u> and scroll bar to explore file, so
they should care about
screen line instead of file line. Is this a bug of Vim?
I too am a bit bothered by this, but not enough to have made a request
on the mailing list :)
Same. I haven't been bothered enough to write a patch, either, though
I've thought about it. It shouldn't be too hard, as a lot of the
functionality is already there; it's just not turned on often enough!
Well, if you (幻想之诚) can find a scroll command which acts by screen
lines (I didn't, but I didn't search the help really in detail),
I'm sure there isn't one. At present, the only time Vim can display its
first screen line without its being the beginning of a file line is in
that 'extreme condition' mentioned above.

Ben.



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
Tim Harper
2008-08-14 21:47:50 UTC
Permalink
Post by Ben Schmidt
Post by ccbrighty .
A extreme condition: When a file contains only a line, but the line
is so long that when wrapped, it can not displayed in a screen. Then
in the default setting,<C-d>,<C-u>, scroll bar, and mouse-scroll all
fail to work.
Wow. I wouldn't have expected complete lack of functionality. That
probably is a bug.
Does 'less' share any code with 'vim'? It sure acts a lot like
it :). Except, it scrolls by screen line, not by file line.

Tim


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Benjamin Fritz
2008-08-11 12:42:36 UTC
Permalink
On Sun, Aug 10, 2008 at 6:31 PM, Tony Mechelynck
Post by Tim Harper
Post by ccbrighty .
Hi Vimmers!
I always need to read texts containing very long lines.
I have 'set wrap' in my .vimrc. then the long lines became a
"paragraph", which
is easy to read(vim do not have a horizontal scroll bar?). But when
I use my mouse to scroll,
it seems that it scrolls 3 'file' lines, not 3 'screen' lines. This
is very unpleasant.
How to set vim to make it scroll 3 'screen' lines, like the scroll
work gedit or Emacs?
A extreme condition: When a file contains only a line, but the line
is so long that when wrapped,
it can not displayed in a screen. Then in the default setting,<C-
d>,<C-u>, scroll bar,
and mouse-scroll all fail to work.
I think we mostly use<C-d> <C-u> and scroll bar to explore file, so
they should care about
screen line instead of file line. Is this a bug of Vim?
I too am a bit bothered by this, but not enough to have made a request
on the mailing list :)
Gary and Christian helped me find this one to make lines display if
:set display=lastline
Tim
Sure, but that isn't what 幻想之诚 asked for. Well, if you (幻想之诚)
can find a scroll command which acts by screen lines (I didn't, but I
didn't search the help really in detail), just use that as the {rhs} of
a mapping (four mappings actually: two ":map"s and two ":imap"s) with
<MouseUp> and <MouseDown> as the {lhs}.
Best regards,
Tony.
--
On Monday mornings I am dedicated to the proposition that all men are
created jerks.
-- Avery
I couldn't find any built-in "scroll by screen line" commands, which
is surprising. The closest I can find are gj and gk, to _move_ by
screen lines. It would be ugly, but you could try a mapping that works
by jumping the cursor to the middle line, setting scrolloff to a high
value, using gj/gk, restoring scrolloff, and jumping the cursor back.
Something like the following mapping would scroll down, for example:

nnoremap {lhs} M:let so_sav=&scrolloff \| set scrolloff=999<CR>gj:let
&scrolloff=so_sav<CR>``

(untested)

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~-
Loading...