Questions tagged [yasnippet]

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.

228 questions
18
votes
2 answers

One yasnippet snippet for multiple modes

I have the following snippet: # -*- mode: snippet -*- # contributor: Song Qiang # key: m # group: Math # name: Inline math \( ... \) # -- \\($1\\)$0 and I want it to be available for both latex-mode and org-mode. How can this…
Dror Atariah
  • 667
  • 6
  • 15
13
votes
1 answer

Insert current date with yasnippet

Since several years I've been using this snippet to insert a date into buffer: # -*- coding: utf-8 -*- # name: date # key: date # -- `(insert (format-time-string "%Y-%m-%d"))`$0 However nowadays I get this annoying warning: Warning (yasnippet):…
user673592
  • 859
  • 7
  • 17
9
votes
1 answer

yasnippet: how to expand a snippet from a string and have the fields recognized?

Q: how do I get yasnippet to expand a text string correctly (recognizing snippet fields) from inside elisp code? A very simple snippet is a just a string of characters with some control characters intermingled. We can also use elisp forms to create…
Dan
  • 32,980
  • 7
  • 102
  • 169
9
votes
2 answers

Warning (yasnippet): modified buffer in a backquote expression

When I use yasnippet, I keep getting this error: Warning (yasnippet): `foo-snippet' modified buffer in a backquote expression. To hide this warning, add (yasnippet backquote-change) to `warning-suppress-types'. I added this line to my config: (setq…
incandescentman
  • 4,221
  • 20
  • 53
7
votes
1 answer

Multiple occurrences of variable in yasnippet snippet

I would like to do create a snippet in which the ${1:} command is present in multiple locations, allowing me to editing in multiple locations at once. In particular I would like this snippet to work as "expected". cout << "${1:} = " << ${1:} <<…
Nisba
  • 905
  • 8
  • 19
7
votes
1 answer

How to put whitespace into Yasnippet Templates?

When I create a new yasnippet template using the 'yas-new-snippet' command, I'm unable to get the leading whitespace to show when the template is expanded in a new document or even tested using 'yas-tryout-snippet'. For example: interface t1 …
6
votes
1 answer

Expand yasnippet only when it's at beginning of the line

How to write snippet condition to expand it only when it's positioned at the beginning of the line?
Navidot
  • 772
  • 5
  • 13
6
votes
4 answers

yasnippets - finding and modifying some snippets

I'm struggling a bit with yasnippet. My question must be very basic but I would like to modify some snippets but I can't locate them. I have for example a snippet style for html-mode but it does not appear where it should be that is either under…
loukios
  • 825
  • 1
  • 9
  • 19
5
votes
1 answer

How do you make an optional field and comma in a yasnippet?

I want to make a snippet for a function with optional arguments. For example something like: myfunc($1, $2, $3) But in this case, $2 may be optional. I know I can press Ctrl-D to skip it, but it leaves behind the comma. How do I get a snippet to…
John Kitchin
  • 11,891
  • 1
  • 20
  • 42
5
votes
2 answers

YASnippet: How to resume (or reactivate) snippets after exiting them

After exiting yasnippet snippets that contain one or more tab stops, I often find myself wanting to go back and modify content that I entered at the tab stops. Of course, I can do this using standard movement and editing commands, but it would be…
itsjeyd
  • 14,666
  • 3
  • 59
  • 87
5
votes
1 answer

Disable default Yasnippet snippets?

How do I disable all pre-existing yasnippet snippets? I only want to use ones that I define myself.
5
votes
1 answer

Need help for a snippet - a for in C

I was switching to vim for the C-support mode, and then I discover yasnippet for emacs, it is awesome I love it ! So now I'm adding basic snippets to insert code and I am currently having a bit of difficulties to make a good for ( ...; ...; ... )…
user3593232
  • 383
  • 1
  • 8
5
votes
3 answers

read clipboard into yasnippet

I am creating a yasnippet to create org-mode link with content like: [[$1:value-read-from-clipboard][$0]] I wish the $1 read value from clipboard (the use-case is: I copy the URL from chrome browser and use this yasnippet to automatically attach…
Xi Xiao
  • 533
  • 4
  • 11
4
votes
0 answers

how to expand a yasnippet snippet after punctuation?

Q: how can I get yasnippet snippets to expand when placed immediately after punctuation? Consider the snippet SNIP. It will expand if preceded by whitespace (eg, here's a SNIP expands), but not when preceded immediately by an alphanumeric character…
Dan
  • 32,980
  • 7
  • 102
  • 169
4
votes
1 answer

How can I disable an individual snippet when in shell-script-mode?

I'm a fairly extensive user of YAsnippet but there is an annoying niggle when I'm working on shell scripts. The default prog-mode snippets includes "fi" which expands to FIXME. This would be fie but it fires every time I close a if<->fi statement in…
stsquad
  • 4,651
  • 29
  • 45
1
2 3 4 5 6 7