how to move the contents of the buffer one line up/down?
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

gnu.emacs.help Profile…
 Up
how to move the contents of the buffer one line up/down?         


Author: Tamas K Papp
Date: Jul 14, 2008 04:17

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.

Thanks,

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


Author: Pascal J. Bourguignon
Date: Jul 14, 2008 04:51

Tamas K Papp gmail.com> writes:
> 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.

scroll-up and scroll-down

C-u 3 M-x scroll-up RET

C-u 6 M-x scroll-down RET

Also, since they're often bound to and you can just type:

C-3 or C-6

--
__Pascal Bourguignon__ http://www.informatimago.com/

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein
no comments
Re: how to move the contents of the buffer one line up/down?         


Author: Peter Dyballa
Date: Jul 14, 2008 04:49

Am 14.07.2008 um 13:17 schrieb Tamas K Papp:
> 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.

(defun scroll-down-in-place (n)
(interactive "p")
(previous-line n)
(scroll-down n))
(defun scroll-up-in-place (n)
(interactive "p")
(next-line n)
(scroll-up n))

Far more on this list.

--
Greetings
Show full article (0.63Kb)
no comments
Re: how to move the contents of the buffer one line up/down?         


Author: Tamas K Papp
Date: Jul 14, 2008 04:55

On Mon, 14 Jul 2008 13:51:01 +0200, Pascal J. Bourguignon wrote:
Show full article (0.77Kb)
no comments
Re: how to move the contents of the buffer one line up/down?         


Author: B. T. Raven
Date: Jul 14, 2008 05:11

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.
>
> Thanks,
>
> Tamas

Look at C-h f scroll-up and scroll-down. For a demo try:

C-u 1 M-x scroll-up

Maybe this works, I don't know. Evaluate it and try it:

(global-set-key [(super q)] (lambda () (interactive) (scroll-up 1)))
no comments
Re: how to move the contents of the buffer one line up/down?         


Author: Pascal J. Bourguignon
Date: Jul 14, 2008 05:49

Tamas K Papp gmail.com> writes:
> Sorry for my ignorance, but on most standard PC keyboards, and
> would be PgUp and PgDown?

I think so. To confirm it, type C-h k PgUp and see if its name is

--
__Pascal Bourguignon__ http://www.informatimago.com/

READ THIS BEFORE OPENING PACKAGE: According to certain suggested
versions of the Grand Unified Theory, the primary particles
constituting this product may decay to nothingness within the next
four hundred million years.
no comments
Re: how to move the contents of the buffer one line up/down?         


Author: Alan Mackenzie
Date: Jul 14, 2008 06:16

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 - and -, so
they'll only work if you're in a GUI system (or you've already enhanced
your terminal keyboard setup).

Additionally, - moves point 6 lines up, and
-- scrolls the screen 6 lines; just the same for
.... And quite a few other goodies, too. Try them!

Enjoy!
Show full article (3.71Kb)
no comments
Re: how to move the contents of the buffer one line up/down?         


Author: Xah
Date: Jul 14, 2008 13:14

On Jul 14, 5:49 am, p...@informatimago.com (Pascal J. Bourguignon)
wrote:
> Tamas K Papp gmail.com> writes:
>
>> Sorry for my ignorance, but on most standard PC keyboards, and
>> would be PgUp and PgDown?
>
> I think so. To confirm it, type C-h k PgUp and see if its name is

One of emacs's problem that set back today's programers from adapting
it is obsolete terminologies. The key names such as , ,
RET, is one of them. (and Meta, of course)

It would be good, if a major new release of emacs, support and use
throughout names like or etc instead (The
is already supported by at least emacs 22, but not used or widely used
in emacs documentations). With this, user don't have to go “huh?” when
reading web pages, guides, blogs, or discussions about typing some
keystrokes or keybindings, etc. (whenever we get a question about
this, we can probably assume 10 or more users had the same question
but didn't bother to ask)
Show full article (1.18Kb)
no comments
Re: how to move the contents of the buffer one line up/down?         


Author: Xah
Date: Jul 14, 2008 13:27

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-") (lambda () (interactive) (scroll-down
2)))
(global-set-key (kbd "C-") (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/
Show full article (2.32Kb)
no comments

RELATED THREADS
SubjectArticles qty Group
setting summary buffer color by header/body contentgnu.emacs.gnus ·