Tip #105: combining move and scroll
tip karma |
Rating 6/3, Viewed by 1208
|
created: |
|
September 3, 2001 17:22 |
|
complexity: |
|
basic |
author: |
|
Andrew Pimlott |
|
as of Vim: |
|
5.7 |
I sometimes found myself moving down a few lines with j, then scrolling down
about the same number of lines with <C-E> to put the cursor in roughly the
same place as it started. I decided I wanted to map <C-J> (and <C-K>,
respectively) to the move-and-scroll operation. First, I did
:map <C-J> <C-E>j
This was pretty good, but behaved funny at the beginning and end of files.
Then, I realized that <C-D> already combined move and scroll, so I figured
that giving <C-D> a count of 1 would do it:
:map <C-J> 1<C-D>
Unfortunately, this permanently attaches a count to <C-D> (ugh!), so I have
to undo that:
:map <C-J> 1<C-D>:set scroll=0<CR>
This has the drawback of not necessarily resetting scroll to its original
value, but since I never change scroll, it's good enough for me. It would
be nice if there were a version of <C-D> that did not have the side-affect
of changing scroll.
Happy vimming,
Andrew
<<using vim to complement Perl's DBI::Shell |
Mail signature rotation: Supersimple one-line solution >>
Additional Notes
|