org.texi 342 KB
Newer Older
Glenn Morris's avatar
Glenn Morris committed
1 2
\input texinfo
@c %**start of header
@setfilename ../../info/org
Glenn Morris's avatar
Glenn Morris committed
4 5
@settitle Org Mode Manual

6 7
@set VERSION 5.23
@set DATE March 2008
Glenn Morris's avatar
Glenn Morris committed
8 9 10 11 12 13 14

@dircategory Emacs
* Org Mode: (org).      Outline-based notes management and organizer
@end direntry

@c Version and Contact Info
@set MAINTAINERSITE @uref{,maintainers webpage}
Glenn Morris's avatar
Glenn Morris committed
16 17
@set AUTHOR Carsten Dominik
@set MAINTAINER Carsten Dominik
18 19
@set MAINTAINEREMAIL @email{carsten at orgmode dot org}
@set MAINTAINERCONTACT @uref{mailto:carsten at orgmode dot org,contact the maintainer}
Glenn Morris's avatar
Glenn Morris committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
@c %**end of header

@c Macro definitions

@c Subheadings inside a table.
@macro tsubheading{text}
@subsubheading \text\
@end ifinfo
@item @b{\text\}
@end ifnotinfo
@end macro

This manual is for Org-mode (version @value{VERSION}).

Copyright @copyright{} 2004, 2005, 2006, 2007, 2008 Free Software Foundation
Glenn Morris's avatar
Glenn Morris committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
and with the Back-Cover Texts as in (a) below.  A copy of the
license is included in the section entitled ``GNU Free Documentation

(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
this GNU Manual, like GNU software.  Copies published by the Free
Software Foundation raise funds for GNU development.''
@end quotation
@end copying

@title Org Mode Manual

@subtitle Release @value{VERSION}
@author by Carsten Dominik

@c The following two commands start the copyright page.
@vskip 0pt plus 1filll
@end titlepage

@c Output the table of contents at the beginning.

@node Top, Introduction, (dir), (dir)
@top Org Mode Manual

@end ifnottex

* Introduction::                Getting started
* Document structure::          A tree works like your brain
* Tables::                      Pure magic for quick formatting
* Hyperlinks::                  Notes in context
* TODO items::                  Every tree branch can be a TODO item
* Tags::                        Tagging headlines and matching sets of tags
84 85 86
* Properties and columns::      Storing information about an entry
* Dates and times::             Making items useful for planning
* Remember::                    Quickly adding nodes to the outline tree
Glenn Morris's avatar
Glenn Morris committed
87 88 89 90 91 92
* Agenda views::                Collecting information into views
* Embedded LaTeX::              LaTeX fragments and formulas
* Exporting::                   Sharing and publishing of notes
* Publishing::                  Create a web site of linked Org-mode files
* Miscellaneous::               All the rest which did not fit elsewhere
* Extensions and Hacking::      It is possible to write add-on code
93 94
* History and Acknowledgments::  How Org-mode came into being
* Main Index::
Glenn Morris's avatar
Glenn Morris committed
95 96 97 98 99 100 101 102 103 104 105
* Key Index::                   Key bindings and where they are described

 --- The Detailed Node Listing ---


* Summary::                     Brief summary of what Org-mode does
* Installation::                How to install a downloaded version of Org-mode
* Activation::                  How to activate Org-mode for certain buffers.
* Feedback::                    Bug reports, ideas, patches etc.
* Conventions::                 Type-setting conventions in the manual
Glenn Morris's avatar
Glenn Morris committed
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128

Document Structure

* Outlines::                    Org-mode is based on outline-mode
* Headlines::                   How to typeset org-tree headlines
* Visibility cycling::          Show and hide, much simplified
* Motion::                      Jumping to other headlines
* Structure editing::           Changing sequence and level of headlines
* Archiving::                   Move done task trees to a different place
* Sparse trees::                Matches embedded in context
* Plain lists::                 Additional structure within an entry
* Drawers::                     Tucking stuff away
* orgstruct-mode::              Structure editing outside Org-mode


* ARCHIVE tag::                 Marking a tree as inactive
* Moving subtrees::             Moving a tree to an archive file


* Built-in table editor::       Simple tables
* Narrow columns::              Stop wasting space in tables
Glenn Morris's avatar
Glenn Morris committed
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
* Column groups::               Grouping to trigger vertical lines
* orgtbl-mode::                 The table editor as minor mode
* The spreadsheet::             The table editor has spreadsheet capabilities.

The spreadsheet

* References::                  How to refer to another field or range
* Formula syntax for Calc::     Using Calc to compute stuff
* Formula syntax for Lisp::     Writing formulas in Emacs Lisp
* Field formulas::              Formulas valid for a single field
* Column formulas::             Formulas valid for an entire column
* Editing and debugging formulas::  Fixing formulas
* Updating the table::          Recomputing all dependent fields
* Advanced features::           Field names, parameters and automatic recalc


* Link format::                 How links in Org-mode are formatted
* Internal links::              Links to other places in the current file
* External links::              URL-like links to the world
* Handling links::              Creating, inserting and following
* Using links outside Org-mode::  Linking from my C source code?
* Link abbreviations::          Shortcuts for writing complex links
* Search options::              Linking to a specific location
* Custom searches::             When the default search is not enough

Internal links

* Radio targets::               Make targets trigger links in plain text.

TODO items

* TODO basics::                 Marking and displaying TODO entries
* TODO extensions::             Workflow and assignments
* Progress logging::            Dates and notes for progress
Glenn Morris's avatar
Glenn Morris committed
165 166 167 168 169 170 171
* Priorities::                  Some things are more important than others
* Breaking down tasks::         Splitting a task into manageable pieces
* Checkboxes::                  Tick-off lists

Extended use of TODO keywords

* Workflow states::             From TODO to DONE in steps
* TODO types::                  I do this, Fred does the rest
Glenn Morris's avatar
Glenn Morris committed
* Multiple sets in one file::   Mixing it all, and still finding your way
174 175 176 177 178 179 180 181
* Fast access to TODO states::  Single letter selection of a state
* Per-file keywords::           Different files, different requirements
* Faces for TODO keywords::     Highlighting states

Progress Logging

* Closing items::               When was this entry marked DONE?
* Tracking TODO state changes::  When did the status change?
Glenn Morris's avatar
Glenn Morris committed
182 183 184 185 186 187 188 189 190 191 192 193


* Tag inheritance::             Tags use the tree structure of the outline
* Setting tags::                How to assign tags to a headline
* Tag searches::                Searching for combinations of tags

Properties and Columns

* Property syntax::             How properties are spelled out
* Special properties::          Access to other Org-mode features
* Property searches::           Matching property values
* Property inheritance::        Passing values down the tree
Glenn Morris's avatar
Glenn Morris committed
195 196 197 198 199 200 201
* Column view::                 Tabular viewing and editing
* Property API::                Properties for Lisp programmers

Column View

* Defining columns::            The COLUMNS format property
* Using column view::           How to create and use column view
* Capturing Column View::       A dynamic block for column view
Glenn Morris's avatar
Glenn Morris committed
203 204 205 206 207 208

Defining Columns

* Scope of column definitions::  Where defined, where valid?
* Column attributes::           Appearance and content of a column

Dates and Times
Glenn Morris's avatar
Glenn Morris committed
210 211 212 213

* Time stamps::                 Assigning a time to a tree entry
* Creating timestamps::         Commands which insert timestamps
* Deadlines and scheduling::    Planning your work
* Clocking work time::
Glenn Morris's avatar
Glenn Morris committed
215 216 217 218 219 220 221 222 223 224 225

Creating timestamps

* The date/time prompt::        How org-mode helps you entering date and time
* Custom time format::          Making dates look differently

Deadlines and Scheduling

* Inserting deadline/schedule::  Planning items
* Repeated tasks::              Items that show up again and again

Glenn Morris's avatar
Glenn Morris committed

228 229 230 231
* Setting up remember::         Some code for .emacs to get things going
* Remember templates::          Define the outline of different note types
* Storing notes::               Directly get the note to where it belongs
* Refiling notes::              Moving a note or task to a project
Glenn Morris's avatar
Glenn Morris committed
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247

Agenda Views

* Agenda files::                Files being searched for agenda information
* Agenda dispatcher::           Keyboard access to agenda views
* Built-in agenda views::       What is available out of the box?
* Presentation and sorting::    How agenda items are prepared for display
* Agenda commands::             Remote editing of org trees
* Custom agenda views::         Defining special searches and views

The built-in agenda views

* Weekly/Daily agenda::         The calendar page with current tasks
* Global TODO list::            All unfinished action items
* Matching tags and properties::  Structured information with fine-tuned search
* Timeline::                    Time-sorted view for single file
* Keyword search::              Finding entries by keyword
Glenn Morris's avatar
Glenn Morris committed
249 250 251 252 253 254 255 256 257 258 259 260 261 262
* Stuck projects::              Find projects you need to review

Presentation and sorting

* Categories::                  Not all tasks are equal
* Time-of-day specifications::  How the agenda knows the time
* Sorting of agenda items::     The order of things

Custom agenda views

* Storing searches::            Type once, use often
* Block agenda::                All the stuff you need in a single buffer
* Setting Options::             Changing the rules
* Exporting Agenda Views::      Writing agendas to files.
* Extracting Agenda Information for other programs::
Glenn Morris's avatar
Glenn Morris committed
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293

Embedded LaTeX

* Math symbols::                TeX macros for symbols and Greek letters
* Subscripts and Superscripts::  Simple syntax for raising/lowering text
* LaTeX fragments::             Complex formulas made easy
* Processing LaTeX fragments::  Previewing LaTeX processing
* CDLaTeX mode::                Speed up entering of formulas


* ASCII export::                Exporting to plain ASCII
* HTML export::                 Exporting to HTML
* LaTeX export::                Exporting to LaTeX
* XOXO export::                 Exporting to XOXO
* iCalendar export::            Exporting in iCalendar format
* Text interpretation::         How the exporter looks at the file

HTML export

* HTML Export commands::        How to invoke LaTeX export
* Quoting HTML tags::           Using direct HTML in Org-mode
* Links::                       Transformation of links for HTML
* Images::                      How to include images
* CSS support::                 Changing the appearence of the output

LaTeX export

* LaTeX export commands::       How to invoke LaTeX export
* Quoting LaTeX code::          Incorporating literal LaTeX code
* Sectioning structure::
Glenn Morris's avatar
Glenn Morris committed
295 296 297 298 299 300

Text interpretation by the exporter

* Comment lines::               Some lines will not be exported
* Initial text::                Text before the first headline
* Footnotes::                   Numbers like [1]
* Quoted examples::             Inserting quoted chnuks of text
Glenn Morris's avatar
Glenn Morris committed
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
* Enhancing text::              Subscripts, symbols and more
* Export options::              How to influence the export settings


* Configuration::               Defining projects
* Sample configuration::        Example projects
* Triggering publication::      Publication commands


* Project alist::               The central configuration variable
* Sources and destinations::    From here to there
* Selecting files::             What files are part of the project?
* Publishing action::           Setting the function doing the publishing
* Publishing options::          Tweaking HTML export
* Publishing links::            Which links keep working after publishing?
* Project page index::          Publishing a list of project files

Sample configuration

* Simple example::              One-component publishing
* Complex example::             A multi-component publishing example


* Completion::                  M-TAB knows what you need
* Customization::               Adapting Org-mode to your taste
* In-buffer settings::          Overview of the #+KEYWORDS
* The very busy C-c C-c key::   When in doubt, press C-c C-c
* Clean view::                  Getting rid of leading stars in the outline
* TTY keys::                    Using Org-mode on a tty
* Interaction::                 Other Emacs packages
* Bugs::                        Things which do not work perfectly

Interaction with other packages

* Cooperation::                 Packages Org-mode cooperates with
* Conflicts::                   Packages that lead to conflicts

Extensions, Hooks and Hacking

* Extensions::                  Existing 3rd-part extensions
* Adding hyperlink types::      New custom link types
* Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
* Dynamic blocks::              Automatically filled blocks
* Special agenda views::        Customized views
* Using the property API::      Writing programs that use entry properties

Tables and Lists in arbitrary syntax
Glenn Morris's avatar
Glenn Morris committed
352 353 354 355

* Radio tables::                Sending and receiving
* A LaTeX example::             Step by step, almost a tutorial
* Translator functions::        Copy and modify
* Radio lists::                 Doing the same for lists.
Glenn Morris's avatar
Glenn Morris committed
357 358 359 360 361 362 363 364 365 366 367 368 369

@end detailmenu
@end menu

@node Introduction, Document structure, Top, Top
@chapter Introduction
@cindex introduction

* Summary::                     Brief summary of what Org-mode does
* Installation::                How to install a downloaded version of Org-mode
* Activation::                  How to activate Org-mode for certain buffers.
* Feedback::                    Bug reports, ideas, patches etc.
* Conventions::                 Type-setting conventions in the manual
Glenn Morris's avatar
Glenn Morris committed
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
@end menu

@node Summary, Installation, Introduction, Introduction
@section Summary
@cindex summary

Org-mode is a mode for keeping notes, maintaining TODO lists, and doing
project planning with a fast and effective plain-text system.

Org-mode develops organizational tasks around NOTES files that contain
lists or information about projects as plain text.  Org-mode is
implemented on top of outline-mode, which makes it possible to keep the
content of large files well structured.  Visibility cycling and
structure editing help to work with the tree.  Tables are easily created
with a built-in table editor.  Org-mode supports TODO items, deadlines,
time stamps, and scheduling.  It dynamically compiles entries into an
agenda that utilizes and smoothly integrates much of the Emacs calendar
and diary.  Plain text URL-like links connect to websites, emails,
Usenet messages, BBDB entries, and any files related to the projects.
For printing and sharing of notes, an Org-mode file can be exported as a
structured ASCII file, as HTML, or (TODO and agenda items only) as an
Glenn Morris's avatar
Glenn Morris committed
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
iCalendar file.  It can also serve as a publishing tool for a set of
linked webpages.

An important design aspect that distinguishes Org-mode from for example
Planner/Muse is that it encourages to store every piece of information
only once.  In Planner, you have project pages, day pages and possibly
other files, duplicating some information such as tasks.  In Org-mode,
you only have notes files.  In your notes you mark entries as tasks,
label them with tags and timestamps.  All necessary lists like a
schedule for the day, the agenda for a meeting, tasks lists selected by
tags etc are created dynamically when you need them.

Org-mode keeps simple things simple.  When first fired up, it should
feel like a straightforward, easy to use outliner.  Complexity is not
imposed, but a large amount of functionality is available when you need
it.  Org-mode is a toolbox and can be used in different ways, for
example as:

@r{@bullet{} outline extension with visibility cycling and structure editing}
@r{@bullet{} ASCII system and table editor for taking structured notes}
@r{@bullet{} ASCII table editor with spreadsheet-like capabilities}
@r{@bullet{} TODO list editor}
@r{@bullet{} full agenda and planner with deadlines and work scheduling}
@r{@bullet{} environment to implement David Allen's GTD system}
@r{@bullet{} a basic database application}
@r{@bullet{} simple hypertext system, with HTML and LaTeX export}
Glenn Morris's avatar
Glenn Morris committed
419 420 421 422 423 424 425 426 427 428 429 430 431 432
@r{@bullet{} publishing tool to create a set of interlinked webpages}
@end example

Org-mode's automatic, context sensitive table editor with spreadsheet
capabilities can be integrated into any major mode by activating the
minor Orgtbl-mode.  Using a translation step, it can be used to maintain
tables in arbitrary file types, for example in La@TeX{}.  The structure
editing and list creation capabilities can be used outside Org-mode with
the minor Orgstruct-mode.

@cindex FAQ
There is a website for Org-mode which provides links to the newest
version of Org-mode, as well as additional information, frequently asked
questions (FAQ), links to tutorials etc.  This page is located at
Glenn Morris's avatar
Glenn Morris committed
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537


@node Installation, Activation, Summary, Introduction
@section Installation
@cindex installation
@cindex XEmacs

@b{Important:} @i{If Org-mode is part of the Emacs distribution or an
XEmacs package, please skip this section and go directly to

If you have downloaded Org-mode from the Web, you must take the
following steps to install it: Go into the Org-mode distribution
directory and edit the top section of the file @file{Makefile}.  You
must set the name of the Emacs binary (likely either @file{emacs} or
@file{xemacs}), and the paths to the directories where local Lisp and
Info files are kept.  If you don't have access to the system-wide
directories, create your own two directories for these files, enter them
into the Makefile, and make sure Emacs finds the Lisp files by adding
the following line to @file{.emacs}:

(setq load-path (cons "~/path/to/lispdir" load-path))
@end example

@b{XEmacs users now need to install the file @file{noutline.el} from
the @file{xemacs} subdirectory of the Org-mode distribution.  Use the

@b{make install-noutline}
@end example

@noindent Now byte-compile and install the Lisp files with the shell

make install
@end example

@noindent If you want to install the info documentation, use this command:

make install-info
@end example

@noindent Then add to @file{.emacs}:

;; This line only if org-mode is not part of the X/Emacs distribution.
(require 'org-install)
@end lisp

@node Activation, Feedback, Installation, Introduction
@section Activation
@cindex activation
@cindex autoload
@cindex global keybindings
@cindex keybindings, global

@b{Important:} @i{If you use copy-and-paste to copy lisp code from the
PDF documentation as viewed by Acrobat reader to your .emacs file, the
single quote character comes out incorrectly and the code will not work.
You need to fix the single quotes by hand, or copy from Info
@end iftex

Add the following lines to your @file{.emacs} file.  The last two lines
define @emph{global} keys for the commands @command{org-store-link} and
@command{org-agenda} - please choose suitable keys yourself.

;; The following lines are always needed.  Choose your own keys.
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-ca" 'org-agenda)
@end lisp

Furthermore, you must activate @code{font-lock-mode} in org-mode
buffers, because significant functionality depends on font-locking being
active.  You can do this with either one of the following two lines
(XEmacs user must use the second option):
(global-font-lock-mode 1)                     ; for all buffers
(add-hook 'org-mode-hook 'turn-on-font-lock)  ; org-mode buffers only
@end lisp

@cindex org-mode, turning on
With this setup, all files with extension @samp{.org} will be put
into Org-mode.  As an alternative, make the first line of a file look
like this:

MY PROJECTS    -*- mode: org; -*-
@end example

@noindent which will select Org-mode for this buffer no matter what
the file's name is.  See also the variable

@node Feedback, Conventions, Activation, Introduction
Glenn Morris's avatar
Glenn Morris committed
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
@section Feedback
@cindex feedback
@cindex bug reports
@cindex maintainer
@cindex author

If you find problems with Org-mode, or if you have questions, remarks,
or ideas about it, please contact the maintainer @value{MAINTAINER} at

For bug reports, please provide as much information as possible,
including the version information of Emacs (@kbd{C-h v emacs-version
@key{RET}}) and Org-mode (@kbd{C-h v org-version @key{RET}}), as well as
the Org-mode related setup in @file{.emacs}.  If an error occurs, a
backtrace can be very useful (see below on how to create one).  Often a
small example file helps, along with clear information about:

@item What exactly did you do?
@item What did you expect to happen?
@item What happened instead?
@end enumerate
@noindent Thank you for helping to improve this mode.

@subsubheading How to create a useful backtrace

@cindex backtrace of an error
If working with Org-mode produces an error with a message you don't
understand, you may have hit a bug.  The best way to report this is by
providing, in addition to what was mentioned above, a @emph{Backtrace}.
This is information from the built-in debugger about where and how the
error occurred.  Here is how to produce a useful backtrace:

Start a fresh Emacs or XEmacs, and make sure that it will load the
original Lisp code in @file{org.el} instead of the compiled version in
@file{org.elc}.  The backtrace contains much more information if it is
produced with uncompiled code.  To do this, either rename @file{org.elc}
to something else before starting Emacs, or ask Emacs explicitly to load
@file{org.el} by using the command line
emacs -l /path/to/org.el
@end example
Go to the @code{Options} menu and select @code{Enter Debugger on Error}
(XEmacs has this option in the @code{Troubleshooting} sub-menu).
Do whatever you have to do to hit the error.  Don't forget to
document the steps you take.
When you hit the error, a @file{*Backtrace*} buffer will appear on the
screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
attach it to your bug report.
@end enumerate

595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615
@node Conventions,  , Feedback, Introduction
@section Typesetting conventions used in this manual

Org-mode uses three types of keywords: TODO keywords, tags, and property
names.  In this manual we use the following conventions:

@table @code
@item TODO
@itemx WAITING
TODO keywords are written with all capitals, even if they are
@item boss
@itemx ARCHIVE
User-defined tags are written in lowercase; built-in tags with special
meaning are written with all capitals.
@item Release
User-defined properties are capitalized; built-in properties with
special meaning are written with all capitals.
@end table

Glenn Morris's avatar
Glenn Morris committed
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742
@node Document structure, Tables, Introduction, Top
@chapter Document Structure
@cindex document structure
@cindex structure of document

Org-mode is based on outline mode and provides flexible commands to
edit the structure of the document.

* Outlines::                    Org-mode is based on outline-mode
* Headlines::                   How to typeset org-tree headlines
* Visibility cycling::          Show and hide, much simplified
* Motion::                      Jumping to other headlines
* Structure editing::           Changing sequence and level of headlines
* Archiving::                   Move done task trees to a different place
* Sparse trees::                Matches embedded in context
* Plain lists::                 Additional structure within an entry
* Drawers::                     Tucking stuff away
* orgstruct-mode::              Structure editing outside Org-mode
@end menu

@node Outlines, Headlines, Document structure, Document structure
@section Outlines
@cindex outlines
@cindex outline-mode

Org-mode is implemented on top of outline-mode.  Outlines allow a
document to be organized in a hierarchical structure, which (at least
for me) is the best representation of notes and thoughts.  An overview
of this structure is achieved by folding (hiding) large parts of the
document to show only the general document structure and the parts
currently being worked on.  Org-mode greatly simplifies the use of
outlines by compressing the entire show/hide functionality into a single
command @command{org-cycle}, which is bound to the @key{TAB} key.

@node Headlines, Visibility cycling, Outlines, Document structure
@section Headlines
@cindex headlines
@cindex outline tree

Headlines define the structure of an outline tree.  The headlines in
Org-mode start with one or more stars, on the left margin@footnote{See
the variable @code{org-special-ctrl-a/e} to configure special behavior
of @kbd{C-a} and @kbd{C-e} in headlines.}.  For example:

* Top level headline
** Second level
*** 3rd level
    some text
*** 3rd level
    more text

* Another top level headline
@end example

@noindent Some people find the many stars too noisy and would prefer an
outline that has whitespace followed by a single star as headline
starters.  @ref{Clean view} describes a setup to realize this.

An empty line after the end of a subtree is considered part of it and
will be hidden when the subtree is folded.  However, if you leave at
least two empty lines, one empty line will remain visible after folding
the subtree, in order to structure the collapsed view.  See the
variable @code{org-cycle-separator-lines} to modify this behavior.

@node Visibility cycling, Motion, Headlines, Document structure
@section Visibility cycling
@cindex cycling, visibility
@cindex visibility cycling
@cindex trees, visibility
@cindex show hidden text
@cindex hide text

Outlines make it possible to hide parts of the text in the buffer.
Org-mode uses just two commands, bound to @key{TAB} and
@kbd{S-@key{TAB}} to change the visibility in the buffer.

@cindex subtree visibility states
@cindex subtree cycling
@cindex folded, subtree visibility state
@cindex children, subtree visibility state
@cindex subtree, subtree visibility state
@table @kbd
@kindex @key{TAB}
@item @key{TAB}
@emph{Subtree cycling}: Rotate current subtree among the states

@end example

The cursor must be on a headline for this to work@footnote{see, however,
the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
beginning of the buffer and the first line is not a headline, then
@key{TAB} actually runs global cycling (see below)@footnote{see the
option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
argument (@kbd{C-u @key{TAB}}), global cycling is invoked.

@cindex global visibility states
@cindex global cycling
@cindex overview, global visibility state
@cindex contents, global visibility state
@cindex show all, global visibility state
@kindex S-@key{TAB}
@item S-@key{TAB}
@itemx C-u @key{TAB}
@emph{Global cycling}: Rotate the entire buffer among the states

@end example

When @kbd{S-@key{TAB}} is called with a numerical prefix N, the CONTENTS
view up to headlines of level N will be shown.
Note that inside tables, @kbd{S-@key{TAB}} jumps to the previous field.

@cindex show all, command
@kindex C-c C-a
@item C-c C-a
Show all.
@kindex C-c C-r
@item C-c C-r
Reveal context around point, showing the current entry, the following
heading and the hierarchy above.  Useful for working near a location
743 744 745 746
that has been exposed by a sparse tree command (@pxref{Sparse trees}) or
an agenda command (@pxref{Agenda commands}).  With prefix arg show, on

Glenn Morris's avatar
Glenn Morris committed
747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836
level, all sibling headings.
@kindex C-c C-x b
@item C-c C-x b
Show the current subtree in an indirect buffer@footnote{The indirect
(@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
@end ifinfo
(see the Emacs manual for more information about indirect buffers)
@end ifnotinfo
will contain the entire buffer, but will be narrowed to the current
tree.  Editing the indirect buffer will also change the original buffer,
but without affecting visibility in that buffer.}.  With numerical
prefix ARG, go up to this level and then take that tree.  If ARG is
negative, go up that many levels.  With @kbd{C-u} prefix, do not remove
the previously used indirect buffer.
@end table

When Emacs first visits an Org-mode file, the global state is set to
OVERVIEW, i.e. only the top level headlines are visible.  This can be
configured through the variable @code{org-startup-folded}, or on a
per-file basis by adding one of the following lines anywhere in the

#+STARTUP: overview
#+STARTUP: content
#+STARTUP: showall
@end example

@node Motion, Structure editing, Visibility cycling, Document structure
@section Motion
@cindex motion, between headlines
@cindex jumping, to headlines
@cindex headline navigation
The following commands jump to other headlines in the buffer.

@table @kbd
@kindex C-c C-n
@item C-c C-n
Next heading.
@kindex C-c C-p
@item C-c C-p
Previous heading.
@kindex C-c C-f
@item C-c C-f
Next heading same level.
@kindex C-c C-b
@item C-c C-b
Previous heading same level.
@kindex C-c C-u
@item C-c C-u
Backward to higher level heading.
@kindex C-c C-j
@item C-c C-j
Jump to a different place without changing the current outline
visibility.  Shows the document structure in a temporary buffer, where
you can use the following keys to find your destination:
@key{TAB}         @r{Cycle visibility.}
@key{down} / @key{up}   @r{Next/previous visible headline.}
n / p        @r{Next/previous visible headline.}
f / b        @r{Next/previous headline same level.}
u            @r{One level up.}
0-9          @r{Digit argument.}
@key{RET}         @r{Select this location.}
@end example
@end table

@node Structure editing, Archiving, Motion, Document structure
@section Structure editing
@cindex structure editing
@cindex headline, promotion and demotion
@cindex promotion, of subtrees
@cindex demotion, of subtrees
@cindex subtree, cut and paste
@cindex pasting, of subtrees
@cindex cutting, of subtrees
@cindex copying, of subtrees
@cindex subtrees, cut and paste

@table @kbd
@kindex M-@key{RET}
@item M-@key{RET}
Insert new heading with same level as current.  If the cursor is in a
plain list item, a new item is created (@pxref{Plain lists}).  To force
creation of a new headline, use a prefix arg, or first press @key{RET}
to get to the beginning of the next line.  When this command is used in
the middle of a line, the line is split and the rest of the line becomes
837 838 839 840 841 842 843 844
the new headline@footnote{If you do not want the line to be split,
customize the variable @code{org-M-RET-may-split-line}.}.  If the
command is used at the beginning of a headline, the new headline is
created before the current line.  If at the beginning of any other line,
the content of that line is made the new heading.  If the command is
used at the end of a folded subtree (i.e. behind the ellipses at the end
of a headline), then a headline like the current one will be inserted
after the end of the subtree.
845 846 847 848
@kindex C-@key{RET}
@item C-@key{RET}
Insert a new heading after the current subtree, same level as the
current headline.  This command works from anywhere in the entry.
Glenn Morris's avatar
Glenn Morris committed
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875
@kindex M-S-@key{RET}
@item M-S-@key{RET}
Insert new TODO entry with same level as current heading.
@kindex M-@key{left}
@item M-@key{left}
Promote current heading by one level.
@kindex M-@key{right}
@item M-@key{right}
Demote current heading by one level.
@kindex M-S-@key{left}
@item M-S-@key{left}
Promote the current subtree by one level.
@kindex M-S-@key{right}
@item M-S-@key{right}
Demote the current subtree by one level.
@kindex M-S-@key{up}
@item M-S-@key{up}
Move subtree up (swap with previous subtree of same
@kindex M-S-@key{down}
@item M-S-@key{down}
Move subtree down (swap with next subtree of same level).
@kindex C-c C-x C-w
@kindex C-c C-x C-k
@item C-c C-x C-w
@itemx C-c C-x C-k
Kill subtree, i.e. remove it from buffer but save in kill ring.
With prefix arg, kill N sequential subtrees.
Glenn Morris's avatar
Glenn Morris committed
877 878
@kindex C-c C-x M-w
@item C-c C-x M-w
Copy subtree to kill ring.  With prefix arg, copy N sequential subtrees.
Glenn Morris's avatar
Glenn Morris committed
880 881 882 883 884 885
@kindex C-c C-x C-y
@item C-c C-x C-y
Yank subtree from kill ring.  This does modify the level of the subtree to
make sure the tree fits in nicely at the yank position.  The yank
level can also be specified with a prefix arg, or by yanking after a
headline marker like @samp{****}.
886 887 888
@kindex C-c C-w
@item C-c C-w
Refile entry to a different location.  @xref{Refiling notes}.
Glenn Morris's avatar
Glenn Morris committed
889 890 891 892 893 894
@kindex C-c ^
@item C-c ^
Sort same-level entries.  When there is an active region, all entries in
the region will be sorted.  Otherwise the children of the current
headline are sorted.  The command prompts for the sorting method, which
can be alphabetically, numerically, by time (using the first time stamp
895 896
in each entry), by priority, and each of these in reverse order.  You
can also supply your own function to extract the sorting key.  With a
Glenn Morris's avatar
Glenn Morris committed
897 898
@kbd{C-u} prefix, sorting will be case-sensitive.  With two @kbd{C-u
C-u} prefixes, duplicate entries will also be removed.
899 900 901 902 903 904 905
@kindex C-c *
@item C-c *
Turn a normal line or plain list item into a headline (so that it
becomes a subheading at its location).  Also turn a headline into a
normal line by removing the stars.  If there is an active region, turn
all lines in the region into headlines.  Or, if the first line is a
headline, remove the stars from all headlines in the region.
Glenn Morris's avatar
Glenn Morris committed
906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
@end table

@cindex region, active
@cindex active region
@cindex transient-mark-mode
When there is an active region (transient-mark-mode), promotion and
demotion work on all headlines in the region.  To select a region of
headlines, it is best to place both point and mark at the beginning of a
line, mark at the beginning of the first headline, and point at the line
just after the last headline to change.  Note that when the cursor is
inside a table (@pxref{Tables}), the Meta-Cursor keys have different

@node Archiving, Sparse trees, Structure editing, Document structure
@section Archiving
@cindex archiving

When a project represented by a (sub)tree is finished, you may want
to move the tree out of the way and to stop it from contributing to the
agenda.  Org-mode knows two ways of archiving.  You can mark a tree with
the ARCHIVE tag, or you can move an entire (sub)tree to a different

* ARCHIVE tag::                 Marking a tree as inactive
* Moving subtrees::             Moving a tree to an archive file
@end menu

@node ARCHIVE tag, Moving subtrees, Archiving, Archiving
@subsection The ARCHIVE tag
@cindex internal archiving

A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
its location in the outline tree, but behaves in the following way:
@itemize @minus
It does not open when you attempt to do so with a visibility cycling
command (@pxref{Visibility cycling}).  You can force cycling archived
subtrees with @kbd{C-@key{TAB}}, or by setting the option
@code{org-cycle-open-archived-trees}.  Also normal outline commands like
@code{show-all} will open archived subtrees.
During sparse tree construction (@pxref{Sparse trees}), matches in
archived subtrees are not exposed, unless you configure the option
During agenda view construction (@pxref{Agenda views}), the content of
archived trees is ignored unless you configure the option
Archived trees are not exported (@pxref{Exporting}), only the headline
is.  Configure the details using the variable
@end itemize

The following commands help managing the ARCHIVE tag:

@table @kbd
@kindex C-c C-x C-a
@item C-c C-x C-a
Toggle the ARCHIVE tag for the current headline.  When the tag is set,
the headline changes to a shadowish face, and the subtree below it is
@kindex C-u C-c C-x C-a
@item C-u C-c C-x C-a
Check if any direct children of the current headline should be archived.
To do this, each subtree is checked for open TODO entries.  If none are
found, the command offers to set the ARCHIVE tag for the child.  If the
cursor is @emph{not} on a headline when this command is invoked, the
level 1 trees will be checked.
@kindex C-@kbd{TAB}
@item C-@kbd{TAB}
Cycle a tree even if it is tagged with ARCHIVE.
@end table

@node Moving subtrees,  , ARCHIVE tag, Archiving
@subsection Moving subtrees
@cindex external archiving

Once an entire project is finished, you may want to move it to a
different location, either in the current file, or even in a different
file, the archive file.

@table @kbd
@kindex C-c C-x C-s
@item C-c C-x C-s
Archive the subtree starting at the cursor position to the location
given by @code{org-archive-location}.  Context information that could be
lost like the file name, the category, inherited tags, and the todo
state will be store as properties in the entry.
@kindex C-u C-c C-x C-s
@item C-u C-c C-x C-s
Check if any direct children of the current headline could be moved to
the archive.  To do this, each subtree is checked for open TODO entries.
If none are found, the command offers to move it to the archive
location.  If the cursor is @emph{not} on a headline when this command
is invoked, the level 1 trees will be checked.
@end table

@cindex archive locations
The default archive location is a file in the same directory as the
current file, with the name derived by appending @file{_archive} to the
current file name.  For information and examples on how to change this,
see the documentation string of the variable
@code{org-archive-location}.  There is also an in-buffer option for
1011 1012 1013 1014 1015 1016 1017
setting this variable, for example@footnote{For backward compatibility,
the following also works: If there are several such lines in a file,
each specifies the archive location for the text below it.  The first
such line also applies to any text before its definition.  However,
using this method is @emph{strongly} deprecated as it is incompatible
with the outline structure of the document.  The correct method for
setting multiple archive locations in a buffer is using a property.}:
Glenn Morris's avatar
Glenn Morris committed
1018 1019 1020 1021 1022 1023

#+ARCHIVE: %s_done::
@end example

1024 1025 1026
If you would like to have a special ARCHIVE location for a single entry
or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
location as the value (@pxref{Properties and columns}).
Glenn Morris's avatar
Glenn Morris committed

1028 1029 1030 1031 1032 1033
When a subtree is moved, it receives a number of special properties that
record context information like the file from where the entry came, it's
outline path the archiving time etc.  Configure the variable
@code{org-archive-save-context-info} to adjust the amount of information

Glenn Morris's avatar
Glenn Morris committed
1034 1035 1036 1037 1038 1039 1040 1041
@node Sparse trees, Plain lists, Archiving, Document structure
@section Sparse trees
@cindex sparse trees
@cindex trees, sparse
@cindex folding, sparse trees
@cindex occur, command

An important feature of Org-mode is the ability to construct
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051
@emph{sparse trees} for selected information in an outline tree, so that
the entire document is folded as much as possible, but the selected
information is made visible along with the headline structure above
it@footnote{See also the variables @code{org-show-hierarchy-above},
@code{org-show-following-heading}, and @code{org-show-siblings} for
detailed control on how much context is shown around each match.}.  Just
try it out and you will see immediately how it works.

Org-mode contains several commands creating such trees, all these
commands can be accessed through a dispatcher:
Glenn Morris's avatar
Glenn Morris committed
1052 1053 1054 1055

@table @kbd
@kindex C-c /
@item C-c /
1056 1057 1058
This prompts for an extra key to select a sparse-tree creating command.
@kindex C-c / r
@item C-c / r
Glenn Morris's avatar
Glenn Morris committed
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068
Occur.  Prompts for a regexp and shows a sparse tree with all matches.
If the match is in a headline, the headline is made visible.  If the
match is in the body of an entry, headline and body are made visible.
In order to provide minimal context, also the full hierarchy of
headlines above the match is shown, as well as the headline following
the match.  Each match is also highlighted; the highlights disappear
when the buffer is changed by an editing command, or by pressing
@kbd{C-c C-c}.  When called with a @kbd{C-u} prefix argument, previous
highlights are kept, so several calls to this command can be stacked.
@end table

Glenn Morris's avatar
Glenn Morris committed
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084
For frequently used sparse trees of specific search strings, you can
use the variable @code{org-agenda-custom-commands} to define fast
keyboard access to specific sparse trees.  These commands will then be
accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
For example:

(setq org-agenda-custom-commands
      '(("f" occur-tree "FIXME")))
@end lisp

@noindent will define the key @kbd{C-c a f} as a shortcut for creating
a sparse tree matching the string @samp{FIXME}.

1085 1086
The other sparse tree commands select headings based on TODO keywords,
tags, or properties and will be discussed later in this manual.
Glenn Morris's avatar
Glenn Morris committed
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107

@kindex C-c C-e v
@cindex printing sparse trees
@cindex visible text, printing
To print a sparse tree, you can use the Emacs command
@code{ps-print-buffer-with-faces} which does not print invisible parts
of the document @footnote{This does not work under XEmacs, because
XEmacs uses selective display for outlining, not text properties.}.
Or you can use the command @kbd{C-c C-e v} to export only the visible
part of the document and print the resulting file.

@node Plain lists, Drawers, Sparse trees, Document structure
@section Plain lists
@cindex plain lists
@cindex lists, plain
@cindex lists, ordered
@cindex ordered lists

Within an entry of the outline tree, hand-formatted lists can provide
additional structure.  They also provide a way to create lists of
checkboxes (@pxref{Checkboxes}).  Org-mode supports editing such lists,
and the HTML exporter (@pxref{Exporting}) parses and formats them.
Glenn Morris's avatar
Glenn Morris committed
1109 1110 1111 1112 1113 1114 1115

Org-mode knows ordered and unordered lists.  Unordered list items start
with @samp{-}, @samp{+}, or @samp{*}@footnote{When using @samp{*} as a
bullet, lines must be indented or they will be seen as top-level
headlines.  Also, when you are hiding leading stars to get a clean
outline view, plain list items starting with a star are visually
indistinguishable from true headlines.  In short: even though @samp{*}
1116 1117 1118
is supported, it may be better to not use it for plain list items.} as
bullets.  Ordered list items start with a numeral followed by either a
period or a right parenthesis, such as @samp{1.} or @samp{1)}.  Items
Glenn Morris's avatar
Glenn Morris committed
1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147
belonging to the same list must have the same indentation on the first
line.  In particular, if an ordered list reaches number @samp{10.}, then
the 2--digit numbers must be written left-aligned with the other numbers
in the list.  Indentation also determines the end of a list item.  It
ends before the next line that is indented like the bullet/number, or
less.  Empty lines are part of the previous item, so you can have
several paragraphs in one item.  If you would like an empty line to
terminate all currently open plain lists, configure the variable
@code{org-empty-line-terminates-plain-lists}.  Here is an example:

** Lord of the Rings
   My favorite scenes are (in this order)
   1. The attack of the Rohirrim
   2. Eowyns fight with the witch king
      + this was already my favorite scene in the book
      + I really like Miranda Otto.
   3. Peter Jackson being shot by Legolas
       - on DVD only
      He makes a really funny face when it happens.
   But in the end, not individual scenes matter but the film as a whole.
@end group
@end example

Org-mode supports these lists by tuning filling and wrapping commands to
deal with them correctly@footnote{Org-mode only changes the filling
settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
@file{filladapt.el}.  To turn this on,  put into @file{.emacs}:
@code{(require 'filladapt)}}.
Glenn Morris's avatar
Glenn Morris committed
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168

The following commands act on items when the cursor is in the first line
of an item (the line with the bullet or number).

@table @kbd
@kindex @key{TAB}
@item @key{TAB}
Items can be folded just like headline levels if you set the variable
@code{org-cycle-include-plain-lists}.  The level of an item is then
given by the indentation of the bullet/number.  Items are always
subordinate to real headlines, however; the hierarchies remain
completely separated.

If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
fixes the indentation of the curent line in a heuristic way.
@kindex M-@key{RET}
@item M-@key{RET}
Insert new item at current level.  With prefix arg, force a new heading
(@pxref{Structure editing}).  If this command is used in the middle of a
line, the line is @emph{split} and the rest of the line becomes the new
1169 1170 1171 1172 1173 1174
item@footnote{If you do not want the line to be split, customize the
variable @code{org-M-RET-may-split-line}.}.  If this command is executed
in the @emph{whitespace before a bullet or number}, the new item is
created @emph{before} the current item.  If the command is executed in
the white space before the text that is part of an item but does not
contain the bullet, a bullet is added to the current line.
Glenn Morris's avatar
Glenn Morris committed
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202
@kindex M-S-@key{RET}
@item M-S-@key{RET}
Insert a new item with a checkbox (@pxref{Checkboxes}).
@kindex S-@key{up}
@kindex S-@key{down}
@item S-@key{up}
@itemx S-@key{down}
Jump to the previous/next item in the current list.
@kindex M-S-@key{up}
@kindex M-S-@key{down}
@item M-S-@key{up}
@itemx M-S-@key{down}
Move the item including subitems up/down (swap with previous/next item
of same indentation).  If the list is ordered, renumbering is
@kindex M-S-@key{left}
@kindex M-S-@key{right}
@item M-S-@key{left}
@itemx M-S-@key{right}
Decrease/increase the indentation of the item, including subitems.
Initially, the item tree is selected based on current indentation.
When these commands are executed several times in direct succession,
the initially selected region is used, even if the new indentation
would imply a different hierarchy.  To use the new hierarchy, break
the command chain with a cursor motion or so.
@kindex C-c C-c
@item C-c C-c
If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1203 1204 1205
state of the checkbox.  If not, this command makes sure that all the
items on this list level use the same bullet.  Furthermore, if this is
an ordered list, make sure the numbering is ok.
Glenn Morris's avatar
Glenn Morris committed
1206 1207 1208 1209 1210
@kindex C-c -
@item C-c -
Cycle the entire list level through the different itemize/enumerate
bullets (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).
With prefix arg, select the nth bullet from this list.
1211 1212 1213 1214
If there is an active region when calling this, all lines will be
converted to list items.  If the first line already was a list item, any
item markers will be removed from the list.  Finally, even without an
active region, a normal line will be converted into a list item.
Glenn Morris's avatar
Glenn Morris committed
1215 1216 1217 1218 1219 1220 1221 1222 1223
@end table

@node Drawers, orgstruct-mode, Plain lists, Document structure
@section Drawers
@cindex drawers
@cindex visibility cycling, drawers

Sometimes you want to keep information associated with an entry, but you
normally don't want to see it.  For this, Org-mode has @emph{drawers}.
1224 1225 1226
Drawers need to be configured with the variable
@code{org-drawers}@footnote{You can define drawers on a per-file basis
with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
Glenn Morris's avatar
Glenn Morris committed
1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271
look like this:

** This is a headline
   Still outside the drawer
      This is inside the drawer.
   After the drawer.
@end example

Visibility cycling (@pxref{Visibility cycling}) on the headline will
hide and show the entry, but keep the drawer collapsed to a single line.
In order to look inside the drawer, you need to move the cursor to the
drawer line and press @key{TAB} there.  Org-mode uses a drawer for
storing properties (@pxref{Properties and columns}).

@node orgstruct-mode,  , Drawers, Document structure
@section The Orgstruct minor mode
@cindex orgstruct-mode
@cindex minor mode for structure editing

If you like the intuitive way the Org-mode structure editing and list
formatting works, you might want to use these commands in other modes
like text-mode or mail-mode as well.  The minor mode Orgstruct-mode
makes this possible.  You can always toggle the mode with @kbd{M-x
orgstruct-mode}.  To turn it on by default, for example in mail mode,

(add-hook 'mail-mode-hook 'turn-on-orgstruct)
@end lisp

When this mode is active and the cursor is on a line that looks to
Org-mode like a headline of the first line of a list item, most
structure editing commands will work, even if the same keys normally
have different functionality in the major mode you are using.  If the
cursor is not in one of those special lines, Orgstruct-mode lurks
silently in the shadow.

@node Tables, Hyperlinks, Document structure, Top
@chapter Tables
@cindex tables
@cindex editing tables

1272 1273
Org-mode comes with a fast and intuitive table editor.  Spreadsheet-like
calculations are supported in connection with the Emacs @file{calc}
(@pxref{Top,Calc,,calc,Gnu Emacs Calculator Manual}).
1277 1278 1279 1280 1281
@end ifinfo
(see the Emacs Calculator manual for more information about the Emacs
@end ifnotinfo
Glenn Morris's avatar
Glenn Morris committed
1282 1283 1284

* Built-in table editor::       Simple tables
* Narrow columns::              Stop wasting space in tables
Glenn Morris's avatar
Glenn Morris committed
1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338
* Column groups::               Grouping to trigger vertical lines
* orgtbl-mode::                 The table editor as minor mode
* The spreadsheet::             The table editor has spreadsheet capabilities.
@end menu

@node Built-in table editor, Narrow columns, Tables, Tables
@section The built-in table editor
@cindex table editor, built-in

Org-mode makes it easy to format tables in plain ASCII.  Any line with
@samp{|} as the first non-whitespace character is considered part of a
table.  @samp{|} is also the column separator.  A table might look like

| Name  | Phone | Age |
| Peter |  1234 |  17 |
| Anna  |  4321 |  25 |
@end example

A table is re-aligned automatically each time you press @key{TAB} or
@key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
the next field (@key{RET} to the next row) and creates new table rows
at the end of the table or before horizontal lines.  The indentation
of the table is set by the first line.  Any line starting with
@samp{|-} is considered as a horizontal separator line and will be
expanded on the next re-align to span the whole table width.  So, to
create the above table, you would only type

@end example

@noindent and then press @key{TAB} to align the table and start filling in

When typing text into a field, Org-mode treats @key{DEL},
@key{Backspace}, and all character keys in a special way, so that
inserting and deleting avoids shifting other fields.  Also, when
typing @emph{immediately after the cursor was moved into a new field
with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
field is automatically made blank.  If this behavior is too
unpredictable for you, configure the variables
@code{org-enable-table-editor} and @code{org-table-auto-blank-field}.

@table @kbd
@tsubheading{Creation and conversion}
@kindex C-c |
@item C-c |
Convert the active region to table. If every line contains at least one
TAB character, the function assumes that the material is tab separated.
If every line contains a comma, comma-separated values (CSV) are assumed.
Glenn Morris's avatar
Glenn Morris committed
If not, lines are split at whitespace into fields.  You can use a prefix
1341 1342 1343
argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
C-u} forces TAB, and a numeric argument N indicates that at least N
consequtive spaces, or alternatively a TAB will be the separator.
Glenn Morris's avatar
Glenn Morris committed
1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435
If there is no active region, this command creates an empty Org-mode
table.  But it's easier just to start typing, like
@kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.

@tsubheading{Re-aligning and field motion}
@kindex C-c C-c
@item C-c C-c
Re-align the table without moving the cursor.
@kindex @key{TAB}
@item @key{TAB}
Re-align the table, move to the next field.  Creates a new row if
@kindex S-@key{TAB}
@item S-@key{TAB}
Re-align, move to previous field.
@kindex @key{RET}
@item @key{RET}
Re-align the table and move down to next row.  Creates a new row if
necessary.  At the beginning or end of a line, @key{RET} still does
NEWLINE, so it can be used to split a table.

@tsubheading{Column and row editing}
@kindex M-@key{left}
@kindex M-@key{right}
@item M-@key{left}
@itemx M-@key{right}
Move the current column left/right.
@kindex M-S-@key{left}
@item M-S-@key{left}
Kill the current column.
@kindex M-S-@key{right}
@item M-S-@key{right}
Insert a new column to the left of the cursor position.
@kindex M-@key{up}
@kindex M-@key{down}
@item M-@key{up}
@itemx M-@key{down}
Move the current row up/down.
@kindex M-S-@key{up}
@item M-S-@key{up}
Kill the current row or horizontal line.
@kindex M-S-@key{down}
@item M-S-@key{down}
Insert a new row above (with arg: below) the current row.
@kindex C-c -
@item C-c -
Insert a horizontal line below current row. With prefix arg, the line
is created above the current line.
@kindex C-c ^
@item C-c ^
Sort the table lines in the region.  The position of point indicates the
column to be used for sorting, and the range of lines is the range
between the nearest horizontal separator lines, or the entire table.  If
point is before the first column, you will be prompted for the sorting
column.  If there is an active region, the mark specifies the first line
and the sorting column, while point should be in the last line to be
included into the sorting.  The command prompts for the sorting type
(alphabetically, numerically, or by time).  When called with a prefix
argument, alphabetic sorting will be case-sensitive.

@kindex C-c C-x M-w
@item C-c C-x M-w
Copy a rectangular region from a table to a special clipboard.  Point
and mark determine edge fields of the rectangle.  The process ignores
horizontal separator lines.
@kindex C-c C-x C-w
@item C-c C-x C-w
Copy a rectangular region from a table to a special clipboard, and
blank all fields in the rectangle.  So this is the ``cut'' operation.
@kindex C-c C-x C-y
@item C-c C-x C-y
Paste a rectangular region into a table.
The upper right corner ends up in the current field.  All involved fields
will be overwritten.  If the rectangle does not fit into the present table,
the table is enlarged as needed.  The process ignores horizontal separator
@kindex C-c C-q
@kindex M-@key{RET}
Glenn Morris's avatar
Glenn Morris committed
@item C-c C-q
@itemx M-@kbd{RET}
Glenn Morris's avatar
Glenn Morris committed
1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479
Wrap several fields in a column like a paragraph.  If there is an active
region, and both point and mark are in the same column, the text in the
column is wrapped to minimum width for the given number of lines.  A
prefix ARG may be used to change the number of desired lines.  If there
is no region, the current field is split at the cursor position and the
text fragment to the right of the cursor is prepended to the field one
line down. If there is no region, but you specify a prefix ARG, the
current field is made blank, and the content is appended to the field

@cindex formula, in tables
@cindex calculations, in tables
@cindex region, active
@cindex active region
@cindex transient-mark-mode
@kindex C-c +
@item C-c +
Sum the numbers in the current column, or in the rectangle defined by
the active region.  The result is shown in the echo area and can
be inserted with @kbd{C-y}.
@kindex S-@key{RET}
@item S-@key{RET}
When current field is empty, copy from first non-empty field above.
When not empty, copy current field down to next row and move cursor
along with it.  Depending on the variable
@code{org-table-copy-increment}, integer field values will be
incremented during copy.  This key is also used by CUA-mode

@kindex C-c `
@item C-c `
Edit the current field in a separate window.  This is useful for fields
that are not fully visible (@pxref{Narrow columns}).  When called with a
@kbd{C-u} prefix, just make the full field visible, so that it can be
edited in place.
@item M-x org-table-import
Import a file as a table.  The table should be TAB- or whitespace
1480 1481 1482 1483 1484 1485
separated.  Useful, for example, to import a spreadsheet table or data
from a database, because these programs generally can write
TAB-separated text files.  This command works by inserting the file into
the buffer and then converting the region to a table.  Any prefix
argument is passed on to the converter, which uses it to determine the
Glenn Morris's avatar
Glenn Morris committed
1486 1487 1488 1489 1490 1491 1492
@item C-c |
Tables can also be imported by pasting tabular text into the org-mode
buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
@kbd{C-c |} command (see above under @i{Creation and conversion}.
@item M-x org-table-export
Export the table as a TAB-separated file.  Useful for data exchange with,
for example, spreadsheet or database programs.
Glenn Morris's avatar
Glenn Morris committed
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668
@end table

If you don't like the automatic table editor because it gets in your
way on lines which you would like to start with @samp{|}, you can turn
it off with

(setq org-enable-table-editor nil)
@end lisp

@noindent Then the only table command that still works is
@kbd{C-c C-c} to do a manual re-align.

@node Narrow columns, Column groups, Built-in table editor, Tables
@section Narrow columns
@cindex narrow columns in tables

The width of columns is automatically determined by the table editor.
Sometimes a single field or a few fields need to carry more text,
leading to inconveniently wide columns.  To limit@footnote{This feature
does not work on XEmacs.} the width of a column, one field anywhere in
the column may contain just the string @samp{<N>} where @samp{N} is an
integer specifying the width of the column in characters.  The next
re-align will then set the width of this column to no more than this

|---+------------------------------|               |---+--------|
|   |                              |               |   | <6>    |
| 1 | one                          |               | 1 | one    |
| 2 | two                          |     ----\     | 2 | two    |
| 3 | This is a long chunk of text |     ----/     | 3 | This=> |
| 4 | four                         |               | 4 | four   |
|---+------------------------------|               |---+--------|
@end group
@end example

Fields that are wider become clipped and end in the string @samp{=>}.
Note that the full text is still in the buffer, it is only invisible.
To see the full text, hold the mouse over the field - a tool-tip window
will show the full content.  To edit such a field, use the command
@kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
open a new window with the full field.  Edit it and finish with @kbd{C-c

When visiting a file containing a table with narrowed columns, the
necessary character hiding has not yet happened, and the table needs to
be aligned before it looks nice.  Setting the option
@code{org-startup-align-all-tables} will realign all tables in a file
upon visiting, but also slow down startup.  You can also set this option
on a per-file basis with:

#+STARTUP: align
#+STARTUP: noalign
@end example

@node Column groups, orgtbl-mode, Narrow columns, Tables
@section Column groups
@cindex grouping columns in tables

When Org-mode exports tables, it does so by default without vertical
lines because that is visually more satisfying in general.  Occasionally
however, vertical lines can be useful to structure a table into groups
of columns, much like horizontal lines can do for groups of rows.  In
order to specify column groups, you can use a special row where the
first field contains only @samp{/}.  The further fields can either
contain @samp{<} to indicate that this column should start a group,
@samp{>} to indicate the end of a column, or @samp{<>} to make a column
a group of its own.  Boundaries between colum groups will upon export be
marked with vertical lines.  Here is an example:

|   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
| / | <> |   < |     |   > |       < |          > |
| # |  1 |   1 |   1 |   1 |       1 |          1 |
| # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
| # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
#+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2))
@end example

It is also sufficient to just insert the colum group starters after
every vertical line you'd like to have:

|  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
| /  | <   |     |     | <       |            |
@end example

@node orgtbl-mode, The spreadsheet, Column groups, Tables
@section The Orgtbl minor mode
@cindex orgtbl-mode
@cindex minor mode for tables

If you like the intuitive way the Org-mode table editor works, you
might also want to use it in other modes like text-mode or mail-mode.
The minor mode Orgtbl-mode makes this possible.  You can always toggle
the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
example in mail mode, use

(add-hook 'mail-mode-hook 'turn-on-orgtbl)
@end lisp

Furthermore, with some special setup, it is possible to maintain tables
in arbitrary syntax with Orgtbl-mode.  For example, it is possible to
construct La@TeX{} tables with the underlying ease and power of
Orgtbl-mode, including spreadsheet capabilities.  For details, see
@ref{Tables in arbitrary syntax}.

@node The spreadsheet,  , orgtbl-mode, Tables
@section The spreadsheet
@cindex calculations, in tables
@cindex spreadsheet capabilities
@cindex @file{calc} package

The table editor makes use of the Emacs @file{calc} package to implement
spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
derive fields from other fields.  While fully featured, Org-mode's
implementation is not identical to other spreadsheets.  For example,
Org-mode knows the concept of a @emph{column formula} that will be
applied to all non-header fields in a column without having to copy the
formula to each relevant field.

* References::                  How to refer to another field or range
* Formula syntax for Calc::     Using Calc to compute stuff
* Formula syntax for Lisp::     Writing formulas in Emacs Lisp
* Field formulas::              Formulas valid for a single field
* Column formulas::             Formulas valid for an entire column
* Editing and debugging formulas::  Fixing formulas
* Updating the table::          Recomputing all dependent fields
* Advanced features::           Field names, parameters and automatic recalc
@end menu

@node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
@subsection References
@cindex references

To compute fields in the table from other fields, formulas must
reference other fields or ranges.  In Org-mode, fields can be referenced
by name, by absolute coordinates, and by relative coordinates.  To find
out what the coordinates of a field are, press @kbd{C-c ?} in that
field, or press @kbd{C-c @}} to toggle the display of a grid.

@subsubheading Field references
@cindex field references
@cindex references, to fields

Formulas can reference the value of another field in two ways.  Like in
any other spreadsheet, you may reference fields with a letter/number
combination like @code{B3}, meaning the 2nd field in the 3rd row.
@c Such references are always fixed to that field, they don't change
@c when you copy and paste a formula to a different field.  So
@c Org-mode's @code{B3} behaves like @code{$B$3} in other spreadsheets.

Org-mode also uses another, more general operator that looks like this:
@end example

Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
or relative to the current column like @samp{+1} or @samp{-2}.

The row specification only counts data lines and ignores horizontal
separator lines (hlines).  You can use absolute row numbers
@samp{1}...@samp{N}, and row numbers relative to the current row like
@samp{+3} or @samp{-1}.  Or specify the row relative to one of the
1669 1670 1671 1672 1673 1674 1675 1676 1677
hlines: @samp{I} refers to the first hline@footnote{Note that only
hlines are counted that @emph{separate} table lines.  If the table
starts with a hline above the header, it does not count.}, @samp{II} to
the second etc.  @samp{-I} refers to the first such line above the
current line, @samp{+I} to the first such line below the current line.
You can also write @samp{III+2} which is the second data line after the
third hline in the table.  Relative row numbers like @samp{-3} will not
cross hlines if the current line is too close to the hline.  Instead,
the value directly at the hline is used.
Glenn Morris's avatar
Glenn Morris committed
1678 1679 1680

@samp{0} refers to the current row and column.  Also, if you omit
either the column or the row part of the reference, the current
row/column is implied.
Glenn Morris's avatar
Glenn Morris committed
1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743

Org-mode's references with @emph{unsigned} numbers are fixed references
in the sense that if you use the same reference in the formula for two
different fields, the same field will be referenced each time.
Org-mode's references with @emph{signed} numbers are floating
references because the same reference operator can reference different
fields depending on the field being calculated by the formula.

Here are a few examples:

@@2$3      @r{2nd row, 3rd column}
C2        @r{same as previous}
$5        @r{column 5 in the current row}
E&        @r{same as previous}
@@2        @r{current column, row 2}
@@-1$-3    @r{the field one row up, three columns to the left}
@@-I$2     @r{field just under hline above current row, column 2}
@end example

@subsubheading Range references
@cindex range references
@cindex references, to ranges

You may reference a rectangular range of fields by specifying two field
references connected by two dots @samp{..}.  If both fields are in the
current row, you may simply use @samp{$2..$7}, but if at least one field
is in a different row, you need to use the general @code{@@row$column}
format at least for the first field (i.e the reference must start with
@samp{@@} in order to be interpreted correctly).  Examples:

$1..$3        @r{First three fields in the current row.}
$P..$Q        @r{Range, using column names (see under Advanced)}
@@2$1..@@4$3    @r{6 fields between these two fields.}
A2..C4        @r{Same as above.}
@@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
@end example

@noindent Range references return a vector of values that can be fed
into Calc vector functions.  Empty fields in ranges are normally
suppressed, so that the vector contains only the non-empty fields (but
see the @samp{E} mode switch below).  If there are no non-empty fields,
@samp{[0]} is returned to avoid syntax errors in formulas.

@subsubheading Named references
@cindex named references
@cindex references, named
@cindex name, of column or field
@cindex constants, in calculations

@samp{$name} is interpreted as the name of a column, parameter or
constant.  Constants are defined globally through the variable
@code{org-table-formula-constants}, and locally (for the file) through a
line like

#+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
@end example

Also properties (@pxref{Properties and columns}) can be used as
1744 1745
constants in table formulas: For a property @samp{:Xyz:} use the name
@samp{$PROP_Xyz}, and the property will be searched in the current
Glenn Morris's avatar
Glenn Morris committed
1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062