You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Org-mode中如何自动创建编号及带缩进的列表项?

How to Implement Auto-Numbered List Features in Org-mode

Hey there, let's tackle your two Org-mode list needs—these are super common workflows, and Org-mode has great built-in tools to handle them smoothly:

1. Auto-Generate Next Numbered Item on Click

Org-mode has native electric indentation that handles this out of the box, but if you want a click-triggered option (or just want to refine the workflow), here's how:

  • First, confirm org-indent-mode is enabled (it’s on by default, but you can toggle it with M-x org-indent-mode if needed).
  • For the simplest approach: When you’re at the end of a line like 1. some item, just press RET (Enter)—Org-mode will automatically insert 2. on the next line, ready for your input.
  • If you specifically want a click-based trigger, add this custom function to your Emacs config (init.el or .emacs):
    (defun org-insert-next-numbered-item ()
      (interactive)
      (end-of-line)
      (org-insert-heading-respect-content)
      (org-do-demote)
      (org-update-numbering))
    
    (global-set-key (kbd "<mouse-2>") 'org-insert-next-numbered-item)
    
    This binds the middle mouse button to insert the next numbered item. Adjust the mouse key (like <mouse-1> for left click) to your preference.

2. Auto-Create Indented Numbered List Items on Click

For nested/indented numbered items, Org-mode’s indentation system keeps things consistent, and you can add click triggers too:

  • Keyboard shortcut first: When on a numbered item, press TAB to indent it into a sub-list—Org-mode will automatically renumber the entire list correctly. Press RET after an indented item, and it’ll keep the indentation and numbering for the new entry.
  • For a click-based indented item, use this modified custom function (binds to right-click here):
    (defun org-insert-indented-numbered-item ()
      (interactive)
      (end-of-line)
      (org-insert-heading-respect-content)
      (org-do-demote)
      (org-do-demote) ; Add another line of this for deeper indentation
      (org-update-numbering))
    
    (global-set-key (kbd "<mouse-3>") 'org-insert-indented-numbered-item)
    
  • Pro tip: Use built-in shortcuts like M-RET (org-meta-return) to insert a new item at the same indent level, or M-S-RET to insert one above—these are reliable and require no custom config.

To keep lists looking clean, add these settings to your config:

(setq org-auto-align-tags t)
(setq org-adapt-indentation t)

内容的提问来源于stack exchange,提问作者Jas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:16:24