Next: , Previous: , Up: Sections   [Contents][Index]


4.2.2 Section Visibility

Magit provides many commands for changing the visibility of sections, but all you need to get started are the next two.

TAB     (magit-section-toggle)

Toggle the visibility of the body of the current section.

C-<tab>     (magit-section-cycle)

Cycle the visibility of current section and its children.

M-<tab>     (magit-section-cycle-diffs)

Cycle the visibility of diff-related sections in the current buffer.

S-<tab>     (magit-section-cycle-global)

Cycle the visibility of all sections in the current buffer.

1     (magit-section-show-level-1)
2     (magit-section-show-level-2)
3     (magit-section-show-level-3)
4     (magit-section-show-level-4)

Show sections surrounding the current section up to level N.

M-1     (magit-section-show-level-1-all)
M-2     (magit-section-show-level-2-all)
M-3     (magit-section-show-level-3-all)
M-4     (magit-section-show-level-4-all)

Show all sections up to level N.

Some functions, which are used to implement the above commands, are also exposed as commands themselves. By default no keys are bound to these commands, as they are generally perceived to be much less useful. But your mileage may vary.

Command: magit-section-show

Show the body of the current section.

Command: magit-section-hide

Hide the body of the current section.

Command: magit-section-show-headings

Recursively show headings of children of the current section. Only show the headings. Previously shown text-only bodies are hidden.

Command: magit-section-show-children

Recursively show the bodies of children of the current section. With a prefix argument show children down to the level of the current section, and hide deeper children.

Command: magit-section-hide-children

Recursively hide the bodies of children of the current section.

Command: magit-section-toggle-children

Toggle visibility of bodies of children of the current section.

When a buffer is first created then some sections are shown expanded while others are not. This is hard coded. When a buffer is refreshed then the previous visibility is preserved. The initial visibility of certain sections can also be overwritten using the hook magit-section-set-visibility-hook.

Variable: magit-section-set-visibility-hook

This hook is run when first creating a buffer and also when refreshing an existing buffer, and is used to determine the visibility of the section currently being inserted.

Each function is called with one argument, the section being inserted. It should return hide or show, or to leave the visibility undefined nil. If no function decides on the visibility and the buffer is being refreshed, then the visibility is preserved; or if the buffer is being created, then the hard coded default is used.

Usually this should only be used to set the initial visibility but not during refreshes. If magit-insert-section--oldroot is non-nil, then the buffer is being refreshed and these functions should immediately return nil.


Next: , Previous: , Up: Sections   [Contents][Index]