Disclaimer: I am new to org-mode.
In org-mode, I sometimes add extra empty lines to make the separation between different tasks clearer when they are expanded. Like so:
** Task 1
*** Subtask 1.1
text text
*** Subtask 1.2
** Task 2
The problem is that when I fold 'Task 1' (by pressing C-tab while on its line) the subtasks and their contents are folded correctly, but the content of 'Subtask 1.2' is also folded (namely, the new line under it).
If I press C-tab while on the line of 'Subtask 1.2', the message 'SUBTREE (NO CHILDREN)' is printed and 'Subtask 1.2' is correctly not folded.
Is this normal? Can I somehow correct this behaviour so that empty content is not folded?
Use (setq org-cycle-separator-lines -1) in your config file.
This will fix it.
Documentation:
Number of empty lines needed to keep an empty line between collapsed trees.
If you leave an empty line between the end of a subtree and the following
headline, this empty line is hidden when the subtree is folded.
Org mode will leave (exactly) one empty line visible if the number of
empty lines is equal or larger to the number given in this variable.
So the default 2 means at least 2 empty lines after the end of a subtree
are needed to produce free space between a collapsed subtree and the
following headline.
If the number is negative, and the number of empty lines is at least -N,
all empty lines are shown.
Related
Context: I'm working with a large text file that is almost excel-like and I'm adding/editing entries. It is a shared file so others can have already edited the file.
I'm working with emacs and I found that they added the command delete-duplicate-lines. This command seems great for pruning extra entries, but it would be nice to know which lines were duplicates (i.e. already existed in the file) so that I would know which entries had already been added. Is there a command that is similar to delete-duplicate-lines, but only points out which lines are duplicates without removing them?
You can use command hlt-highlight-line-dups-region from the Highlight library, to highlight all sets of duplicate lines in the region or (if no active region) in the buffer.
By default, leading and trailing whitespace are ignored
when checking for duplicates, but this is controlled by option
hlt-line-dups-ignore-regexp. And with a prefix arg the behavior
effectively acts opposite to the value of that option. So if the
option says not to ignore whitespace and you use a prefix arg then
whitespace is ignored, and vice versa.
You can also control the colors/faces used to highlight each set of duplicates.
In emacs org-mode, when I make a new sub-heading,(org-insert-subheading), sometimes it adds a blank line, sometimes it doesn't based on some pattern in text above.
Can I force emacs to never insert a line break?
I.e,
* Heading 1
** Heading 2 #no line breaks.
This is controlled by the variable org-blank-before-new-entry:
Should `org-insert-heading' leave a blank line before new heading/item?
The value is an alist, with `heading' and `plain-list-item' as CAR, and a boolean flag as CDR. The cdr may also be the symbol `auto', in which case Org will look at the surrounding headings/items and try to make an intelligent decision whether to insert a blank line or not.
On my version of emacs, the default for both items is auto. To never insert blank lines, set both to nil:
(setf org-blank-before-new-entry '((heading . nil) (plain-list-item . nil)))
I think this is controlled by the variable org-blank-before-new-entry. As per the Org documentation:
Should org-insert-heading leave a blank line before new heading/item?
The value is an alist, with heading and plain-list-item as CAR,
and a boolean flag as CDR. The cdr may also be the symbol `auto', in
which case Org will look at the surrounding headings/items and try to
make an intelligent decision whether to insert a blank line or not.
For plain lists, if org-list-empty-line-terminates-plain-lists is set,
the setting here is ignored and no empty line is inserted to avoid breaking
the list structure.
The default value is '((heading . auto) (plain-list-item . auto)), so it normally will insert a newline before a heading (the auto part in the heading). You can specify Never when you customize the variable, and it will not insert a newline.
When using Emacs's text mode, I find it handy to use the default indentation method with below features:
When I am at some indentation level, hitting C-j
will automatically bring me to the next line with identical
indentation level
When I hit Tab, the indentation will further right by some amount (usually to align with the next word in previous line)
However, I find it difficult to go back by one indentation level. E.g. If the current cursor is at the position of | as below:
Line 0: some text here
Line 1: some text here
Line 2: some text here
|Line 3: some text here
what can I do to bring the cursor to align with "L" in line 1?
Note the amount of spaces of each level indentation is not fixed, as it is usually align to the 2nd word of previous line. So it seems not proper to use reducing 4-spaces as indent to previous level.
Just curious whether there is any predefined / customized function for such purpose. It seems natural to seek for a corresponding "left-indent" command if the text-editor already provides a "right-indent" one.
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.
If I press <TAB> it does not collapse ** Section A, as I would need the cursor to be on the stars for this to work.
If I press <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")?
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.
How can I make Emacs automatically wrap lines of text that I've already written such that no line is longer than, say, 70 characters. In other words, I'd like to do "auto-fill-mode" after-the-fact.
Is this possible?
Look at fill-paragraph and fill-region. If I remember correctly, it's bound to M-q by default. To set the line width, use C-xf.
In addition to fill-paragraph and fill-region, take a look at these commands:
file-individual-paragraphs: "Fill paragraphs of uniform indentation within the region.
This command divides the region into "paragraphs",
treating every change in indentation level or prefix as a paragraph boundary,
then fills each paragraph using its indentation level as the fill prefix.
There is one special case where a change in indentation does not start
a new paragraph. This is for text of this form:
foo> This line with extra indentation starts
foo> a paragraph that continues on more lines.
These lines are filled together."
fill-nonuniform-paragraphs: "Fill paragraphs within the region, allowing varying indentation within each.
This command divides the region into "paragraphs",
only at paragraph-separator lines, then fills each paragraph
using as the fill prefix the smallest indentation of any line
in the paragraph."