python
python

Reputation: 1940

Is there any way to scroll emacs view like mouse scroll?

If start emacs in the GUI mode, there is usually a scroll bar on the right. If I drag the scroll bar up and down ,then the cursor will not move but the view of the emacs will change according to the scroll bar pos. Is there any to do this but without draging the scroll-bar or mouse-scroll? By the way, I know the command : Ctrl+V, M-V, but this is not exactly what I want . I want such effect, it's looks like that you click the emacs window and drag it up and down , if i use Ctrl+v ,ctl+n or such command, the cursor will change it's position,this is not exactly what i want.

Upvotes: 1

Views: 317

Answers (2)

PascalVKooten
PascalVKooten

Reputation: 21443

I believe what you want is centered-cursor-mode. Whenever you scroll up or down, whether it is with one line, page down/up or the mouse, the cursor will stay in the middle.

Upvotes: 1

Dmitry
Dmitry

Reputation: 3665

By default, C-v calls scroll-up-command, and M-vscroll-down-command. When called without a prefix argument, they scroll by the whole screen, but M-2 C-v, for example, will scroll-up by two lines.

If you want a simpler way to do that, you can define your own commands that would call scroll-up with predefined arguments and bind them to keys of your choosing.

Note that as soon you scroll enough to leave the cursor behind, it will move anyway.

Another useful command is recenter-top-bottom, bound to C-l.

Upvotes: 1

Related Questions