Skip to main content

4.2.1 Section Movement

To move within a section use the usual keys (C-p, C-n, C-b, C-f etc), whose global bindings are not shadowed. To move to another section use the following commands.

p     (magit-section-backward)

When not at the beginning of a section, then move to the beginning of the current section. At the beginning of a section, instead move to the beginning of the previous visible section.

n     (magit-section-forward)

Move to the beginning of the next visible section.

M-p     (magit-section-backward-siblings)

Move to the beginning of the previous sibling section. If there is no previous sibling section, then move to the parent section instead.

M-n     (magit-section-forward-siblings)

Move to the beginning of the next sibling section. If there is no next sibling section, then move to the parent section instead.

^     (magit-section-up)

Move to the beginning of the parent of the current section.

The above commands all call the hook magit-section-movement-hook. Any of the functions listed below can be used as members of this hook.

You might want to remove some of the functions that Magit adds using add-hook. In doing so you have to make sure you do not attempt to remove function that haven’t even been added yet, for example:

(with-eval-after-load 'magit-diff
(remove-hook 'magit-section-movement-hook
'magit-hunk-set-window-start))

variable magit-section-movement-hook

This hook is run by all of the above movement commands, after arriving at the destination.

function magit-hunk-set-window-start

This hook function ensures that the beginning of the current section is visible, provided it is a hunk section. Otherwise, it does nothing.

Loading magit-diff adds this function to the hook.

function magit-section-set-window-start

This hook function ensures that the beginning of the current section is visible, regardless of the section’s type. If you add this to magit-section-movement-hook, then you must remove the hunk-only variant in turn.

function magit-log-maybe-show-more-commits

This hook function only has an effect in log buffers, and point is on the "show more" section. If that is the case, then it doubles the number of commits that are being shown.

Loading magit-log adds this function to the hook.

function magit-log-maybe-update-revision-buffer

When moving inside a log buffer, then this function updates the revision buffer, provided it is already being displayed in another window of the same frame.

Loading magit-log adds this function to the hook.

function magit-log-maybe-update-blob-buffer

When moving inside a log buffer and another window of the same frame displays a blob buffer, then this function instead displays the blob buffer for the commit at point in that window.

function magit-status-maybe-update-revision-buffer

When moving inside a status buffer, then this function updates the revision buffer, provided it is already being displayed in another window of the same frame.

function magit-status-maybe-update-stash-buffer

When moving inside a status buffer, then this function updates the stash buffer, provided it is already being displayed in another window of the same frame.

function magit-status-maybe-update-blob-buffer

When moving inside a status buffer and another window of the same frame displays a blob buffer, then this function instead displays the blob buffer for the commit at point in that window.

function magit-stashes-maybe-update-stash-buffer

When moving inside a buffer listing stashes, then this function updates the stash buffer, provided it is already being displayed in another window of the same frame.

user option magit-update-other-window-delay

Delay before automatically updating the other window.

When moving around in certain buffers, then certain other buffers, which are being displayed in another window, may optionally be updated to display information about the section at point.

When holding down a key to move by more than just one section, then that would update that buffer for each section on the way. To prevent that, updating the revision buffer is delayed, and this option controls for how long. For optimal experience you might have to adjust this delay and/or the keyboard repeat rate and delay of your graphical environment or operating system.