YASnippet is a template system for Emacs. It allows you to type an abbreviation and automatically expand it into function templates. Bundled language templates includes: C, C++, C#, Perl, Python, Ruby, SQL, LaTeX, HTML, CSS and more.
Questions tagged [yasnippet]
107 questions
33
votes
5 answers
Display all snippets of yasnippet
What's a nice way to display all snippets available to yasnippet to the current major mode?

Reactormonk
- 21,472
- 14
- 74
- 123
12
votes
1 answer
How can I trigger an event when a Yasnippet macro can fire?
I love yasnippet, but it requires time to memorize. What I'd like to do is change the cursor color when I am at a point that can expand a macro (and back again when there is no macro). However, from what I remember about how yasnippet works, that…

angelixd
- 300
- 1
- 7
9
votes
1 answer
emacs 24 autocomplete yasnippet
I've been having a problem for a while, and it's giving me a real headache. I'm using emacs 24.2.1
The next code is my configuration for auto-complete, and when I run it without yasnippet everything is running smoothly.
(add-to-list 'load-path…

silgon
- 6,890
- 7
- 46
- 67
8
votes
1 answer
About auto complete and yasnippet in emacs
I'm using auto-complete and yasnippet in Emacs and I am confused by their settings. I placed the following code in my .emacs:
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas/global-mode 1)
(global-set-key (kbd…

Boris
- 555
- 7
- 22
8
votes
1 answer
How can I expand a snippet within a snippet using YASnippet?
At the YASnippet site I noticed the following description of yas/triggers-in-field :
If non-nil, yas/next-field-key can trigger stacked expansions, that is
a snippet expansion inside another snippet expansion. Otherwise,
yas/next-field-key just…

qubital
- 1,064
- 9
- 14
6
votes
1 answer
How to remove indentation for a line in yasnippet for python-mode?
I would like to close my if statements with a comment indicating the condition checked in the if statement. I am using yasnippet with emacs and the snippet I use is this:
# -*- mode: snippet -*-
# name: if
# key: if
# group : control structure
#…

evolute
- 65
- 3
6
votes
1 answer
Deactivate specific yasnippets in Emacs
With Yasnippet recently updated from MELPA, I would like to be able to deactivate only the snippets xxx and todo that come with text-mode. The first expands with x and the other with t, which bother me because I write math texts in org-mode and I…

rvf0068
- 1,339
- 9
- 19
6
votes
3 answers
Regular expression as a trigger
One of the code conventions at work is to include a padding of one space inside square brackets and parenthesis. So list[ index ], not list[index]. Adding those spaces can be annoying, so I tried writing a snippet:
# name: Bracket
# key: [
# --
[…

Arturo E
- 303
- 2
- 8
6
votes
4 answers
Unset 'Tab' binding for yasnippet?
The Tab keybinding of yasnippet often overwrites other useful keys.
Is there a way to disable Tab binding of Yasnippet to enable other Tab usage?

Hanfei Sun
- 45,281
- 39
- 129
- 237
6
votes
4 answers
Insert yasnippet by name
I want to insert a specific yasnippet as part of a function in emacs-lisp. Is there a way to do that?
The only command that seems related is yas/insert-snippet, but it simply opens a popup with all the options and the documentation doesn't say…

Malabarba
- 4,473
- 2
- 30
- 49
5
votes
1 answer
Use yasnippets of other mode in web mode
I would like to make the snippets in js-mode available in web-mode.
There is no too many snippets in web-mode. What should I do to use javascript or HTML snippets in web-mode?

ppn029012
- 580
- 1
- 6
- 20
5
votes
2 answers
Emacs Yasnippet for Different Coding Styles
Just recently started using yasnippet for emacs and really like the way it works, however I've run into a minor nuisance I'd like some help to solve if possible.
One snippet I like in particular is the "for"-snippet, i.e.:
# -*- mode: snippet -*-
#…

Xaldew
- 560
- 5
- 18
5
votes
3 answers
yasnippet conditional transformation on leaving field
I'm writing a snippet (for Go) and would like to have a field conditionally transformed when I move to the next field. Specifically, I want the field empty if I leave it unedited, and enclosed in parentheses if I leave it edited.
My unsuccessful…

ivarg
- 755
- 1
- 8
- 11
5
votes
2 answers
How to make the yasnippet as the auto-complete backend?
I want to make the yasnippet as the backend of the auto-complete. However, it doesn't work. what I do after searched the internet is as follows:
get the auto-complete-yasnippet.el, add some elisp in the .emacs like this:
(add-to-list 'load-path
…

toolchainX
- 1,998
- 3
- 27
- 43
5
votes
2 answers
Installing YASnippet
I have installed YASnippet and configured it with this:
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet-0.6.1c")
(require 'yasnippet) ;; not yasnippet-bundle
(yas--initialize)
(yas/load-directory…

AlexanderNajafi
- 1,631
- 2
- 25
- 39