help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to move the contents of the buffer one line up/down?


From: Xah
Subject: Re: how to move the contents of the buffer one line up/down?
Date: Mon, 14 Jul 2008 13:27:14 -0700 (PDT)
User-agent: G2/1.0

Like Alan Mackenzie, i also defined a keystroke to scroll screen up or
down by just 1 line. Had this for like 10 years.

basically i just have this:

(global-set-key (kbd "C-<up>") (lambda () (interactive) (scroll-down
2)))
(global-set-key (kbd "C-<down>") (lambda () (interactive) (scroll-up
2)))

However, this week i actually took them off. :D
Relying on mouse scroll wheel instead, or recenter (default to C-l),
just for a fresh change. If mouse is not available, well possibly i
don't need to scroll screen in such way since as far as i looked, vast
majority of major editors (X-code, Visual Studio, Eclipse) don't have
it (i might be wrong since i haven't yet checked in detail). (so this
is to experiment)

Part of the other reason is that i can free up the modifier+arrow
keyspace for more consistent use for, say, sexp navigation or other,
havn't really decided what.

  Xah
∑ http://xahlee.org/

☄

On Jul 14, 6:16 am, Alan Mackenzie <address@hidden> wrote:
> Hi, Tamas!
>
> On Mon, Jul 14, 2008 at 11:17:29AM +0000, Tamas K Papp wrote:
> > Hi,
> > I know that I can "center" my cursor with C-l.  But sometimes it would be
> > really useful to do the following: have the contents of the buffer move
> > up or down a couple of lines, with the cursor staying in the same place.
> > What function would do that?  Then I could bind it to a key.
>
> There isn't really a decent existing Emacs function, but it's very easy
> to write them.  In fact, these commands were the first I ever wrote.
> Here they are: I've bound them to <shift>-<up> and <shift>-<down>, so
> they'll only work if you're in a GUI system (or you've already enhanced
> your terminal keyboard setup).
>
> Additionally, <ctrl>-<up> moves point 6 lines up, and
> <ctrl>-<shift>-<up> scrolls the screen 6 lines; just the same for
> ...<down>.  And quite a few other goodies, too.  Try them!
>
> Enjoy!
>
> #########################################################################
> (defun scrollup-n (&optional n)
>   "Scroll the text up n (default 1) lines."
>   (interactive "p")
>   (scroll-up (or n 1))
> )
> (global-set-key [S-down] 'scrollup-n)
>
> (defun scrolldown-n (&optional n)
>   "Scroll the text down n (default 1) lines."
>   (interactive "p")
>   (scroll-down (or n 1))
> )
> (global-set-key [S-up] 'scrolldown-n)
>
> ...



reply via email to

[Prev in Thread] Current Thread [Next in Thread]