Search code examples
emacsorg-mode

Tree-like layouts in Org-Mode


Say I want to enter information in an Org file that could be displayed in a tree-like format. Can Org help me with this?

For example I want Org to display a hierarchy of entities as follows:

ROOT
├── foo
│   └── bar
├── baz
├── bax
├── src
│   ├── main
│   │   ├── java
│   │   │   └── something
│   │   └── fine
│   ├── yes
│   └── no

How can I enter this information in a way that Org understands it so that it can render the tree as above?


Solution

  • You might be interested by ditaa block for this:

    #+name: tree
    #+begin_src ditaa
      ROOT      
      |
      +--foo
      |  +----bar
      |  
      +--baz   
      +--bax   
      +--src   
      |  +--main
      |  |  +---java
      |  |  |   +---something
      |  |  |
      |  |  +---fine
      |  |
      |  +--yes
      |  +--no
    #+end_src
    

    typing C-c ` in the src block will put you in artist-mode, a mode made for editing ascii art and that should make editing those tree easier.