how to tell vim not to change cursor position on the screen after PageDown/PageUp

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

RE: how to tell vim not to change cursor position on the screen after PageDown/PageUp

Andrew Robinson-2
I tried all of the suggestions here, and my cursor *always* moves to the
top/bottom of the screen when scrolling.

-----Original Message-----
From: A. J. Mechelynck [mailto:[hidden email]]
Sent: Monday, May 23, 2005 4:32 PM
To: David J. Weller-Fahy
Cc: [hidden email]
Subject: Re: how to tell vim not to change cursor position on the screen
after PageDown/PageUp

David J. Weller-Fahy wrote:
> * A. J. Mechelynck <[hidden email]> [2005-05-23 13:57
+0200]:

>
>>Try the following mappings:
>>
>> :map <PageUp> <C-U><C-U>
>> :map <PageDown> <C-D><C-D>
>
>
> Thanks! I've been irritated by the default behavior of PageUp and
> PageDown for years now, but never enough to search for a solution. While
> catching up on the vim list, I found an answer waiting.
>
> Again, thanks!
>
> Regards,

If you want to use them also in Insert mode, you can use in addition

        :imap <PageUp>   <C-O><C-U><C-O><C-U>
        :imap <PageDown> <C-O><C-D><C-O><C-D>

see ":help i_CTRL-O"

Best regards,
Tony.



Reply | Threaded
Open this post in threaded view
|

Re: how to tell vim not to change cursor position on the screen after PageDown/PageUp

A.J.Mechelynck
In reply to this post by David Fishburn
David Fishburn wrote:

> Thanks for the suggestion Tony.
>
> I had something else that didn't quite do it.
>
> I think in your last post you didn't have the vmaps:
>
> nmap <silent> <PageDown>      <C-D><C-D>
> nmap <silent> <PageUp>        <C-U><C-U>
> imap <silent> <PageDown> <C-O><C-D><C-O><C-D>
> imap <silent> <PageUp>   <C-O><C-U><C-O><C-U>
> vmap <silent> <PageDown>      <C-D><C-D>
> vmap <silent> <PageUp>        <C-U><C-U>
>
> Dave
>
>
>
>

In my previous post I had "map" (with no prefix), which covers both nmap
and vmap (and also omap i.e., for a "motion" after a command such as y d
etc.). (Similarly, for mappings which apply to both imap and cmap I use
"map!" also with no prefix but with bang.)

See ":help map-overview"

Best regards,
Tony.

Reply | Threaded
Open this post in threaded view
|

RE: how to tell vim not to change cursor position on the screen after PageDown/PageUp

John (Eljay) Love-Jensen
In reply to this post by Andrew Robinson-2
Hi Andrew,

I tried the <C-U><C-U> and <C-D><C-D> trick, and it worked for me.  And kept the cursor on the same visual line in the window (not always in the exact same column, due to tabs).

Before more fiddling with mapping of <PageUp> and <PageDown>, do Ctrl-U and Ctrl-D work for you?

:help CTRL-U
:help CTRL-D

I normally use Ctrl-B and Ctrl-F, which don't have the "keep cursor on the same line on the screen" behavior you desire.

But Ctrl-U and Ctrl-D should have your desired behavior.

--Eljay

12