Say I am in org-mode in a document with the following structure:
* First headline
* Second headline
** Section A
Here is one line
Here is another line
blah, blah
** Section B
Say the cursor is on the line that reads Here is another line
. I would like to collapse ** Section A
from this location with a keyboard shortcut.
<TAB>
it does not collapse ** Section A
, as I would need the cursor to be on the stars for this to work.<Shift-TAB>
it collapses all outlines, and not the current one.Is there any way to cycle through the collapsing of the outline in scope (i.e. the "current outline")?
Emacs does not actually understand you are editing an Org document, yet. To enable Org mode on your current document, type M-x org-mode which will enable the Org mode on the current document.
Emacs has included Org Mode as a major mode by default since 2006. Bastien Guerry is the current maintainer, in cooperation with an active development community. Since its success in Emacs, some other systems now provide functions to work with org files.
You can customize the behaviour of the org-cycle
command (which is bound to <TAB>
) by changing the value of org-cycle-emulate-tab
.
To get it to collapse ** Section A
when your cursor is on Here is another line
add the following line to your .emacs file:
(setq org-cycle-emulate-tab 'white)
The white
will allow you to still use <TAB>
to indent in empty lines. From org-mode Github:
org-cycle-emulate-tab's value is t
Documentation:
Where should `org-cycle' emulate TAB.
nil Never
white Only in completely white lines
whitestart Only at the beginning of lines, before the first non-white char
t Everywhere except in headlines
exc-hl-bol Everywhere except at the start of a headline
If you don't mind doing this in two steps:
C-c C-p
: move the cursor to the previous heading (** Section A
in your example)
TAB
: fold the section
This method doesn't require any configuration, as long as you get used to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With