GNU Emacs
Org
Refiling and Archiving

Refiling and Archiving

Once information is in the system, it may need to be moved around. Org provides Refile, Copy and Archive commands for this. Refile and Copy helps with moving and copying outlines. Archiving helps to keep the system compact and fast.

Refile and Copy

When reviewing the captured data, you may want to refile or to copy some of the entries into a different list, for example into a project. Cutting, finding the right location, and then pasting the note is cumbersome. To simplify this process, you can use the following special command:

C-c C-w (org-refile)

Refile the entry or region at point. This command offers possible locations for refiling the entry and lets you select one with completion. The item (or all items in the region) is filed below the target heading as a subitem. Depending on org-reverse-note-order, it is either the first or last subitem.

By default, all level 1 headlines in the current buffer are considered to be targets, but you can have more complex definitions across a number of files. See the variable org-refile-targets for details. If you would like to select a location via a file-path-like completion along the outline path, see the variables org-refile-use-outline-path and org-outline-path-complete-in-steps. If you would like to be able to create new nodes as new parents for refiling on the fly, check the variable org-refile-allow-creating-parent-nodes. When the variable ~org-log-refile~(note: Note the corresponding STARTUP options logrefile, lognoterefile, and nologrefile.) is set, a timestamp or a note is recorded whenever an entry is refiled.

C-u C-c C-w

Use the refile interface to jump to a heading.

C-u C-u C-c C-w (org-refile-goto-last-stored)

Jump to the location where org-refile last moved a tree to.

C-2 C-c C-w

Refile as the child of the item currently being clocked.

C-3 C-c C-w

Refile and keep the entry in place. Also see org-refile-keep to make this the default behavior, and beware that this may result in duplicated ID properties.

C-0 C-c C-w or C-u C-u C-u C-c C-w (org-refile-cache-clear)

Clear the target cache. Caching of refile targets can be turned on by setting org-refile-use-cache. To make the command see new possible targets, you have to clear the cache with this command.

C-c M-w (org-refile-copy)

Copying works like refiling, except that the original note is not deleted.

C-c C-M-w (org-refile-reverse)

Works like refiling, except that it temporarily toggles how the value of org-reverse-note-order applies to the current buffer. So if org-refile would append the entry as the last entry under the target header, org-refile-reverse will prepend it as the first entry, and vice-versa.

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. Archiving is important to keep your working files compact and global searches like the construction of agenda views fast.

C-c C-x C-a (org-archive-subtree-default)

Archive the current entry using the command specified in the variable org-archive-default-command.

Moving a tree to an archive file

The most common archiving action is to move a project tree to another file, the archive file.

C-c C-x C-s or short C-c $ (org-archive-subtree)

Archive the subtree starting at point position to the location given by org-archive-location.

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, check each subtree for open TODO entries. If none is found, the command offers to move it to the archive location. If point is not on a headline when this command is invoked, check level 1 trees.

C-u C-u C-c C-x C-s

As above, but check subtree for timestamps instead of TODO entries. The command offers to archive the subtree if it does contain a timestamp, and that timestamp is in the past.

The default archive location is a file in the same directory as the current file, with the name derived by appending _archive to the current file name. You can also choose what heading to file archived items under, with the possibility to add them to a datetree in a file. For information and examples on how to specify the file and the heading, see the documentation string of the variable org-archive-location.

There is also an in-buffer option for setting this variable, for example:

#+ARCHIVE: %s_done::

If you would like to have a special archive location for a single entry or a (sub)tree, give the entry an ARCHIVE property with the location as the value (see Properties and Columns).

When a subtree is moved, it receives a number of special properties that record context information like the file from where the entry came, its outline path the archiving time etc. Configure the variable org-archive-save-context-info to adjust the amount of information added.

When org-archive-subtree-save-file-p is non-nil, save the target archive buffer.

Internal archiving

If you want to just switch off—for agenda views—certain subtrees without moving them to a different file, you can use the ARCHIVE tag.

A headline that is marked with the ARCHIVE tag (see Tags) stays at its location in the outline tree, but behaves in the following way:

It does not open when you attempt to do so with a visibility cycling command (see Visibility Cycling). You can force cycling archived subtrees with C-c C-TAB, or by setting the option org-cycle-open-archived-trees. Also normal outline commands, like org-show-all, open archived subtrees.

During sparse tree construction (see Sparse Trees), matches in archived subtrees are not exposed, unless you configure the option org-sparse-tree-open-archived-trees.

During agenda view construction (see Agenda Views), the content of archived trees is ignored unless you configure the option org-agenda-skip-archived-trees, in which case these trees are always included. In the agenda you can press v a to get archives temporarily included.

Archived trees are not exported (see Exporting), only the headline is. Configure the details using the variable org-export-with-archived-trees.

Archived trees are excluded from column view unless the variable org-columns-skip-archived-trees is configured to nil.

The following commands help manage the ARCHIVE tag:

C-c C-x a (org-toggle-archive-tag)

Toggle the archive tag for the current headline. When the tag is set, the headline changes to a shadowed face, and the subtree below it is hidden.

C-u C-c C-x a

Check if any direct children of the current headline should be archived. To do this, check each subtree for open TODO entries. If none is found, the command offers to set the ARCHIVE tag for the child. If point is not on a headline when this command is invoked, check the level 1 trees.

C-c C-TAB (org-cycle-force-archived)

Cycle a tree even if it is tagged with ARCHIVE.

C-c C-x A (org-archive-to-archive-sibling)

Move the current entry to the Archive Sibling. This is a sibling of the entry with the heading Archive and the archive tag. The entry becomes a child of that sibling and in this way retains a lot of its original context, including inherited tags and approximate position in the outline.

Manual
Org Mode 9.7.39
Source Ref
release_9.7.39
Source
View upstream