Note: the original content of this post has been edited on.
Text snippets can help write code and test faster and, over time, I started appreciating and using Yasnippet.
Yankpad is based on OrgMode: snippets are defined in a OrgMode file
yankpad.org, by default), in which Level 1 headings are used to
group snippets and Level 2 headings are used to define a snippet. In
this way all snippets are defined in a single, nicely structured,
First level headers of the Yankpad can be associated to major modes,
in which case the corresponding snippets are made available in buffers
visited in the major mode. All snippets belonging to a level-1 heading
can be enabled manually by invoking
If used in conjunction with Yasnippet, snippets can use the syntax and expansion capabilities provided by this package, which make snippets defined with Yankpad much more useful.
For instance the following portion of my Yankpad defines a snippet
Cash Withdrawal, which is available in any buffer in
hledger-mode. The snippet uses Emacs-lisp to insert the current date
(formatted as YYYY-MM-DD, e.g., 2018-10-20) and sets two tab stops
* hledger-mode ** cw: Cash Withdrawal :src: #+BEGIN_SRC `(format-time-string "%Y-%2m-%2d" (current-time))` Me cash $1 bank $0 #+END_SRC
The example shows two other nice features of Yankpad, namely,
shortcuts and literate programming styled snippets. In fact, the
string at the beginning of the heading allows to invoke snippet
expansion by writing
cw in the buffer and then call
:src: tag specifies that the snippet is
defined in a source code drawer.
(require 'yasnippet nil t) (if (featurep 'yasnippet) (yas-global-mode 1)) (require 'yankpad nil t) (global-set-key "\C-x?" 'yankpad-insert) (global-set-key "\C-x/" 'yankpad-expand)
Yankpad also defines features to separate the definition of snippets in different files.