我正在尝试制作一棵自然规划树(遵循大卫·艾伦的《Getting Things Done》的建议),它看起来像:
* Natural Planning Model
** ITEM 1
*** Purpose and Principles (Why)
*** Outcome Visioning
*** Brainstorming
*** Organizing
*** Identifying next actions
** ITEM 2...
** ITEM 3...
Run Code Online (Sandbox Code Playgroud)
我想将ITEM 1的大纲结构复制到新的 ITEMS 中。但问题是我已经在ITEM 1的子树中填写了很多信息。
我的一般问题是:有没有办法删除树的内容但不删除它的标题(以 * 开头的行)?同样,有没有办法复制树的结构而不复制它的内容?
小智 2
我不记得在 Org 中执行此操作的命令,但您可以很容易地创建自己的命令。
(defun org-copy-subtree-headings-as-kill ()
"Copy headings of current subtree as kill."
(interactive)
(save-excursion
(org-back-to-heading)
(let* ((el (org-element-at-point))
(beg (org-element-property :begin el))
(end (org-element-property :end el))
(tree (buffer-substring-no-properties beg end)))
(with-temp-buffer
(insert tree)
(goto-char (point-min))
(while (not (eobp))
(if (looking-at-p "^\\*")
(forward-line)
(delete-region (point-at-bol) (1+ (point-at-eol)))))
(kill-new (buffer-string))))))
Run Code Online (Sandbox Code Playgroud)
此外,如果这些标题通常是同一组标题,您可以使用 yasnippet 模板。
要从当前树中删除内容(而不是复制标题),您可以缩小到子树并keep-lines
使用^\*
.
归档时间: |
|
查看次数: |
891 次 |
最近记录: |