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.

227 questions
27
votes
2 answers

How to make yasnippet and company work nicer?

In my emacs, let's say, I use a "elisp" yasnippet to extend a lisp block in org-mode. But before I extend it, company is triggered first, which gives me a menu like "1. elisp1, 2. elisp2" without an option "elisp". Now if I use tab to extend…
Leu_Grady
  • 2,420
  • 1
  • 17
  • 27
19
votes
1 answer

Get Company to show suggestions for Yasnippet names

I use the packages Company mode and Yasnippet. When I'm typing in a buffer, I get autocompletion suggestions from Company. For Yasnippet, I have a directory which contains the snippets. In that directory I have for example, the file foo.yasnippet.…
ReneFroger
  • 3,855
  • 22
  • 63
16
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
  • 637
  • 6
  • 15
13
votes
3 answers

Is it possible to make yasnippets to expand snippets inside an org-mode babel section in the appropriate mode?

For example I have an org mode that has the following #+BEGIN_SRC emacs-lisp #+END_SRC Is it possible to configure yasnippets in such a way so all emacs-lisp-mode snippets can be expanded inside that block but not outside it?
Rafa de Castro
  • 1,231
  • 10
  • 14
12
votes
2 answers

Is there a yasnippet producing a prepopulated doxygen comment?

For the following C++ function: bool importantStuff(double a, double b); It should output the following snippet, perhaps without the tags: /** * * * @param a * @param b
Rovanion
  • 975
  • 7
  • 20
12
votes
3 answers

Expanding Snippets in evil-insert-mode

I just moved to spacemacs from vim and am a complete newbie with emacs. I cannot figure out how to expand yasnippets while in evil-insert-mode. I know yasnippet is available because I can choose from the available snippets using Spc i s. However I'd…
owise1
  • 351
  • 2
  • 7
11
votes
1 answer

Insert code chunk in R Markdown with yasnippet and polymode

I am trying to write a yasnippet to insert code chunks into an R Markdown file. I use polymode to have multiple major modes (markdown, ESS[S]) in a single file. This is my snippet: # -*- mode: snippet -*- # name: chunk # key: chunk # -- \`\`\`{r…
Kara Woo
  • 422
  • 3
  • 9
11
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
  • 839
  • 7
  • 17
9
votes
1 answer

Yasnippet not working with auto-complete-mode

I am just starting to experiment with Yasnippet, and it worked very well until I tried to combine it with auto-complete-mode. The problem is that Auto-Complete is taking over completely. For example, in c-mode I can type pr and then press TAB to…
Håkon Hægland
  • 3,608
  • 1
  • 20
  • 51
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,584
  • 6
  • 98
  • 168
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,111
  • 16
  • 53
8
votes
1 answer

How can I prevent yasnippet from breaking when I update my packages?

After packages have been updated, the location of the loaded elisp files will change to be in the folder of the new version of the package. Yasnippet attempts to lazily load snippets for the file it was installed it, when I open a file in a major…
Squidly
  • 1,499
  • 14
  • 17
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 …
7
votes
3 answers

Convert the first character to uppercase/capital letter using yasnippet

Q: I have the following Yasnippet, which looks like this: MYNAME - $1 (`(insert-mode-description)`). $2 When I insert the snippet, the cursor starts on $1. Then I begin with typing. I would like to convert the first character of the sentence…
ReneFroger
  • 3,855
  • 22
  • 63
6
votes
1 answer

(setq yas-snippet-dirs ...) not working

I am unable to set up yasnippet the way I want to set it up. I only want to use yasnippet for a particular set of modes, so I don't want to use yas-global-mode. I only want to use my own snippets, not the ones that come pre-packaged with the MELPA…
Jackson
  • 1,218
  • 9
  • 19
1
2 3
15 16