I posted this question on stackoverflow earlier, but perhaps this is a better place for it?
I am looking for a way to left-align text in Org-mode so that the paragraphs line up like in FoldingText. Here is an example:
* Headline number 1
** Headline number 2 [0/2]
Here is some text
before our first unordered list:
- List item 1
- List item 2
And here is a checklist:
- [ ] Do this first
- [ ] Do this next
** Headline number 4
I've tried using align-regexp
but I am having trouble figuring the correct regex string... any ideas?
Here's an update
I got this working with the following code:
(defun align-ft (p1 p2)
"Align outlines like FoldingText"
(interactive "r")
(align-regexp p1 p2 "\\(^\\*+\\s-\\|^-\\s-\\|^\\)." -1 0 nil)
)
The only problem is that it aligns text by adding spaces, and I don't want spaces hard-coded into the document. I just want it to display, as if the spaces were there (like in org-indent-mode
). Also, this code requires the region to be highlighted and ultimately, I just want it to auto-align the entire document, as I type.
Any ideas?
org-indent-mode
? Or are you aware of that, and that's not what you need? On top on that, may be(setq org-hide-leading-stars t)
?org-indent-mode
now. But this gives me more of an outline view. What I would like to find is a way to shift all the markup characters (stars and hyphens) into the margin area, so that the text stays nicely aligned.align-regexp
, but this will almost certainly break those parts of org that expect headlines stars (*) to start at the left margin, not at a variable number of spaces in from the margin. Given how fundamental headlines are, that's probably most of org mode.