2

如何添加自己的org-mode easy template

 3 years ago
source link: https://www.lujun9972.win/blog/2018/04/03/%E5%A6%82%E4%BD%95%E6%B7%BB%E5%8A%A0%E8%87%AA%E5%B7%B1%E7%9A%84org-mode-easy-template/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

如何添加自己的org-mode easy template

org-mode提供了Easy Templates功能,可以让你方便地插入常用结构,比如

按下 <s <TAB> 会自动扩展成:

#+BEGIN_SRC 

#+END_SRC

org-mode已经预设了很多常用的结构,不过如果你想要新增自己的结构的话也很简单,只需要修改 org-structure-template-alist 这个变量就行了。

比如,我经常要插入elisp代码块,那么我可以这样配置:

(add-to-list 'org-structure-template-alist
             '("se" "#+BEGIN_SRC emacs-lisp\n?\n#+END_SRC"))

这里list中第一个参数 se 为触发扩展的键,也就是说我按下 <se <TAB> 就会自动扩展成list中第二个参数的内容

#+BEGIN_SRC emacs-lisp

#+END_SRC

其中第二个参数中的 ? 指明了扩展后光标所在的位置,也就是两行中间的空行那个位置。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK