<?xml version="1.0" encoding="utf-8"?> Emacs 使用YASnippet

UP | HOME

Emacs 使用YASnippet

Table of Contents

  • 1 安装YASnippent
  • 2 安装 org-mode字典
  • 3 org-mode中使用教程
  • 4 YASnippet增加模板

1 安装YASnippent

$ cd ~/.emacs.d/plugins
$ git clone https://github.com/capitaomorte/yasnippet

Add the following in your .emacs file:

(add-to-list 'load-path"~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas/global-mode 1)

2 安装 org-mode字典

# git clone git://github.com/rvf0068/yasnippets.git
## 复制yasnippets/org-mode目录到yasnippet/snippets/目录下
# cp -r yasnippets/org-mode /root/.emacs.d/site-lisp/yasnippet/snippets/

3 org-mode中使用教程

Snippets for org-mode. See Yasnippet in Github.

They have bindings C-c y plus an extra letter.

I have added a condition statement so that the snippets can be expanded only at the beginning of the line.

name key letter explanation
#+begin_ …#+end_ block b
#+srcname:..#+begin_src…#+end_src sb s source block with name
attr_html ath alt="$1" img class="aligncenter"
attr_latex atl ${1:width=$2\textwidth}
author aut a inserts #+author:
corollary cor c (uses reftex)
definition def d (uses reftex)
ditaa dit #+begin_ditaa,+end_ditaa
el el #+begin_src emacs-lisp,+end_src
email email inserts #+email:
equation eqn e (uses reftex)
figure fig f asks for image file
language lan inserts #+language: (with choice)
LaTeX class lcl inserts #+latex_class: (with choice)
LaTeX header lhe inserts #+latex_header:
lemma lem l (uses reftex)
options opt o inserts #+options:
proof prf
properties folded properties inserts visibility folded property
proposition pro p (uses reftex)
startup sta inserts #+startup:
text text inserts #+text:
theorem thm t (uses reftex)
tikz-picture tkz z (uses reftex)
title title inserts #+title:

4 YASnippet增加模板

这么强大的工具要是没有定制功能简直太可惜了.不过我找了很久也没有找到.以为直接编辑文件就可以的,但是结果还是不成功.

还得一步一个脚印的来.幸好有元旦的5天假期,否则不知道我会不会因为没有耐心而放弃研究它了呢.

下面举个例子增加 cnblogs的bash着色模块.

  1. ESC x yas/new-snippet 来进入新建snippet的buffer,可以看到以下的内容:

      # -*- mode: snippet -*-# name: # key: # binding: direct-keybinding# expand-env: ((some-var some-value))# type: command# --

    其中:

    • name: 是在YASnippet中显示的名字.
    • key: 是触发这个snippet所用的关键字.
    • binding 和 expand-env, type 是一些高级特征,这里不做研究.
  2. 将上面的内容改为(不需要的行删掉):
       # -*- mode: snippet -*-# name: src_bash# key: bash# --#+BEGIN_HTML<div class="cnblogs_Highlighter"><pre class="brush:bash">${1:#!/bin/bash}$0</pre></div>#+END_HTML

    其中: ${N: Some Text} 的内容被称为字段, N 是tab stop序号(顺序是从$1-$N的),冒号后面的文本则是默认值.最近 $0 被称为YASnippet的退出点,即一个key被展开为snippet,并按顺序走完所有的tab stop之后光标停留的点.

  3. 保存: C-x C-s 保存在 org-mode/bash文件里面即可.
  4. 重启之后,可以使用.

Date: 2012-12-30 Sun

Author: liweilijie

Org version 7.9.2 with Emacs version 23

Validate XHTML 1.0

转载于:https://www.cnblogs.com/liweilijie/archive/2012/12/30/2840081.html

Emacs 使用YASnippet相关推荐

  1. emacs python开发环境_配置Emacs下的Python开发环境

    特性 在Linux论坛上总有人问Python用什么IDE比较好,然后总会有人回答说Emacs.最近开始学Python,也花了点时间研究怎么配置Emacs,发现没有想象中的那么麻烦.这篇文章大致上来自于 ...

  2. emacs python ide_Emacs Python IDE win7 x64

    安装平台 win7 x64 ,emacs 23.3.1 snippet工具,可自定义一些模板: .emacs 配置如下 (add-to-list 'load-path "~/.emacs.d ...

  3. YASnippet - emacs 的代码片段管理工具

    添加 snippet M-x 然后输入 yas-new-snippet 回车 RET,会出现一个新的 buffer # -*- mode: snippet -*-# name: # key: # -- ...

  4. emacs参考资料整理

    spacemacs dired模式用法: https://blog.slegetank.com/blog/20170106-dired.html Emacs文件管理神器--dired常用操作说明 - ...

  5. 一个很好的 emacs 配置文件范例

    2019独角兽企业重金招聘Python工程师标准>>> 一个很好的 emacs 配置文件范例 (custom-set-variables;; custom-set-variables ...

  6. 用Emacs进行Java开发

    <?xml version="1.0" encoding="utf-8"?> 用Emacs进行Java开发 用Emacs进行Java开发 Table ...

  7. java环境卡顿_解决Emacs在windows使用的问题,比如环境设置、卡顿……

    发现Emacs下编辑代码时非常卡顿,环境设置也不方便,百度了一通,集合一些设置如下,发现这个神器真的是很爽,秒杀一众IDE 一.建一个bat文件设置启动变量 windows下,环境设置可以自己写一个b ...

  8. 钗黛双收:若你也同Vim难割舍,却又看Emacs情切切

    作者: C. Minos Niu 原文:请猛击. 1 钗黛双收:若你也同Vim难割舍,却又看Emacs情切切 (引子) 这篇文章分享我的一些经历,写给和我一样对娇小的Vim难以割舍,又在抱上Emacs ...

  9. 【积水成渊-逐步定制自己的Emacs神器】4:Emacs自动补全

    前言 本文介绍了Emacs里的自动补全功能,包括其内置的缓冲区文件名补全和使用扩展package实现的文本的补全和程序代码的补全功能等. 本文提到的几个package(或mode): ido-mode ...

最新文章

  1. Struts 2(八):文件上传
  2. 【pmcaff专栏】一个“Uber”血染中国共享经济
  3. 安卓手机 python控制_PyAndroidControl:使用python脚本控制你的安卓设备
  4. 学用 TStringGrid [1] - ColCount、RowCount、Cells
  5. 云服务器php版本修改,云服务器 更改php版本
  6. My SQL-4 函数
  7. Ubuntu自定义服务
  8. (原創) 如何為Blog加上簡體中文(繁體中文)翻譯? (Web) (CSS) (JavaScript)
  9. python selenium2 动态调试
  10. QTimer定时器的使用,判断ros是否关闭,ros关闭后关闭窗口
  11. 神经滤镜为什么不能用,ps神经网络滤镜安装包
  12. html怎样在视频上添加文字,视频底部加一行文字 如何在视频上加文字
  13. 整型最大值java,整数的最大值
  14. UEFI是什么?与BIOS的区别在哪?
  15. 小程序自动化测试框架原理剖析
  16. 简单聊聊VisualStudio的断点调试
  17. Python有什么用?Python 的 10 个实际用途
  18. Apache-Hop构建本地web版本问题汇总
  19. 教育界杂志教育界杂志社教育界编辑部2022年第10期目录
  20. Python学习笔记——Python和基础知识

热门文章

  1. 安卓如何实现多级结构树_数据结构-树(树基本实现C++)
  2. HTML5文档结构主体结构 语义结构,html5组织文档结构.pdf
  3. php 生成非对称密钥,php实现非对称加密
  4. Java项目:前台+后台精品水果商城系统设计和实现(java+Springboot+ssm+mysql+jsp+maven)
  5. show在php,show.php
  6. 【js】通过js代码改变html表单中的数据
  7. python3 线程池源码解析_5分钟看懂系列:Python 线程池原理及实现
  8. python自己做电子词典_python实现电子词典
  9. 微信小程序(canvas)画图保存到本地相册(wepy)
  10. LinkedIn领英发布《2016中国人才趋势报告》