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.

Filter by
Sorted by
Tagged with
1
vote
1answer
104 views

Can you setup a snippet with two choices, where the second choice depends on the first choice?

I am trying to setup a snippet to add a src-block header to an emacs org-mode src-block. I want to get a list of possible headers to choose from, which I can get in this snippet (the org-babel-headers ...
1
vote
1answer
252 views

How to define yasnippet templates using elisp instead of the file system?

I would like to use YASnippet template system to expand abbreviations. (I don't want to use abbrev-mode which use space or symbols for expansion.) It is not convenient to create a new file for each ...
1
vote
1answer
229 views

Context suggestion for yasnippet

I would like to create a yasnippet snippet as follow: pressing weather I would like that would be inserted the following text current weather = with the cursor after the = (this can be done with ...
1
vote
1answer
290 views

yassnippet snippet to insert current timestamp

I would like to create a yasnippet snippet which will insert automatically the current timestamp. I have found a code which actually prints the timestamp but I do not know how to integrate into a ...
1
vote
1answer
266 views

Put placeholder and default value in yassnippet

I would like to create a yassnippet with a placeholder, so something like value = $1(insert_value) with the meaning that I would like to see the text "insert value" but when I press TAB and then ...
1
vote
1answer
86 views

How to temporary disable yassnipet snippet in snippet

I'm new to yassnipet and it's been awesome but I hit a wall. I have the following snippet: $1 = errors.WithMessage($1, $2))$0 In most of the use cases on $1 I enter err which expands to another ...
1
vote
2answers
179 views

Yasnippets won't expand in git-commit-mode?

I have written a snippet for git-commit-mode. However when I'm writing a commit message (from Magit), the snippet won't trigger. Does anyone know how to fix this? I have yasnippet version 20160924....
1
vote
1answer
215 views

Is an “Electric” YASnippet possible?

I want to emulate (and even replace) some electric modes (eg. cperl-electric, ruby-electric) with my own custom templates using yasnippet, but it doesn't seem to be possible - can someone enlighten me?...
1
vote
1answer
347 views

How mirror another line in Yasnippet?

I have the following snippet /* ---------------------------------------------------- * METHOD ${1:$$(upcase yas-text)}. * ---------------------------------------------------- */ public function f$1($...
1
vote
1answer
146 views

Yasnippet minor mode working in lisp-interaction-mode but not in emacs-lisp-mode

I wanted to test yasnippet for editing Emacs Lisp files. After installing it from the package manager, the problem is that it works fine from the *scratch* buffer but not when editing a Lisp file ...
1
vote
1answer
74 views

Company-yasnippet doesn't see yasnippet template in lisp

Config: (use-package yasnippet :ensure t :hook (prog-mode . yas-minor-mode) ) (use-package yasnippet-snippets :ensure t :after yas) (use-package common-lisp-snippets :ensure t :after ...
1
vote
1answer
34 views

How to pass the current scopes function symbol as an argument to an elisp function

I am trying to create an org-capture template which works with yankpad and yasnippets to such that if I am working with some c code like this: example.c static int somefunc(int a) { if (a ==5) { ...
1
vote
1answer
25 views

How to replace the highlighted word in yasnippet?

After the snippet gets expanded the cursor is put to the first section (long_name). What key do I need to press in order to replace long_name? Evil operations like e.g. cw or ce change long or to ...
1
vote
1answer
83 views

YASnippet: Remove parts of expanded snippet when exiting the current active area based on condition

I want to write a snippet for LaTeX sum that behaves like this: I write "sum" and trigger snippet expansion. "sum" becomes "\sum_{$1}^{$2} $0", with $1 being the first entry point, $2 the second one ...
1
vote
1answer
50 views

how to append arbitrary string to yasnippet placeholder field

I would like to know how to append a default string to a placeholder. For example, I currently have: # -*- mode: snippet -*- # name: render template # key: rt # group: Flask # contributor: Jon ...
1
vote
1answer
276 views

Yasnippet: Prompting the user for information to fill in a latex snippet

I write a snippet to insert a theorem environment into a latex document, based upon some snippets created by another project: https://github.com/madsdk/yasnippets-latex . In the snippet below, the ...
1
vote
1answer
78 views

Mirrors produce spurious indentation under mma-mode

NB: This problem seems to be limited to mma-mode (for Mathematica). For example, suppose I define a snippet like this: # key: test # name: test # -- $1 $1 Then, I test it (with C-c C-t). After I ...
1
vote
1answer
95 views

Yasnippet increment function name

I have a small snippet like this: # -*- mode: snippet -*- # name: options # key: vop # -- var options = { target: '#$1', beforeSubmit: showRequest, success: showResponse }$0 ...
1
vote
1answer
130 views

Getting the value of previos field with yasnippet

Sometimes it would be handy to get the previously entered field values, and process them. Example: the second field (function name) of this snippet is always the camelCase version of the first field ...
1
vote
1answer
319 views

Space eaten in yasnippet template

NOTE: I use the symbol ␣ to represent the character SPACE (U+0020) for visibility. I have a template like this: ${1:$$(yas-choose-value (with-current-buffer "foo-buf" (foo-get-name-list)))}␣[label="$...
1
vote
1answer
83 views

How can I get “this->” by inputting “this.”?

I want to input this. and get this-> in c++-mode. I tried abbrev-mode and yasnippet, but failed. In abbrev-mode, I defined an abbrev this to get this using . as a trigger key, but soon as I typed ...
1
vote
1answer
150 views

Iterate over string in YAS Snippet?

I'm new to emacs/LISP and would like guidance how to achieve the following output I'd like to type "color glass hat sport" in a single string ($1) that will be converted to the following: Color = "C"...
1
vote
1answer
157 views

Yasnipped expand also after character

I am trying to write a snipped mode for writing subscripts in LaTeX: # -*- mode: snippet -*- # name: sub # key: _ # -- _{\text{$1}}$0 If I type just _ + TAB it expands correctly as expencted. But ...
1
vote
1answer
296 views

Yasnippet not being loaded automatically in php-mode

I have a list of yasnippets for php mode in ~/.emacs.d/yasnippets/php-mode. One of the them is var_dump.yasnippet: #name : var_dump # key: vd # -- var_dump($0); The weird thing is that it's not ...
1
vote
0answers
25 views

Don't understand the keybinding for auto-yasnippet

I am looking to use auto-yasnippet but I don't understand the keybindings they are suggesting such as H-w and H-y. I haven't seen any keybinding that starts with H so I am not sure what that is. I ...
1
vote
0answers
7 views

yas-expand doesn't trigger reindent in aggressive-indent-mode

I'm trying to make a call to yas-expand doesn't trigger aggressive-indent. I'm guessing this is because yas-expand, for some reason, doesn't trigger a call to after-change-functions into which ...
1
vote
0answers
39 views

Autodocument function for C Code

Suppose i have this line of code presenting a C function prototype: int sum_Func(int a, int *b) I want an Emacs lisp function that adds the function description (initialization) according to its ...
1
vote
0answers
18 views

How can insert a yasnippet snippet not from the current major mode?

Sometimes I am editing multiligual documents (like jinja templates) and I just want to insert a snippet from something that is not in the current major mode. Furthermore, some document types don't ...
1
vote
0answers
47 views

using org table as yasnippet input

I'm using yasnippets to create code blocks in org mode to document and execute DevOps activities. To improve productivity, it would be nice to have a possibility to create org tables with rows of ...
1
vote
0answers
148 views

Using auto-insert and yasnippet to insert variables into template

I've been reading this and this, trying to figure out how to have an org-mode in-buffer settings template such as this: # # -*- mode: org -*- # # -*- coding: utf-8 -*- #+TITLE: $1 #+AUTHOR: `(user-...
1
vote
0answers
29 views

Massively long text boxes and yasnippet highlighting

Why are my text boxes and yasnippet field highlights so massively long? Is there a way to change this behavior? If so, what are the necessary steps that need to be taken to solve this issue? The ...
1
vote
0answers
856 views

How do I get code signature snippets with lsp-mode/lsp-ui/company-lsp?

I see on the front page of https://github.com/tigersoldier/company-lsp when you type the function name it autocompletes not just the rest of the name, but the signature as a snippet, enabling you to ...
1
vote
1answer
65 views

Setting An Org Heading Property From Yasnippet

I have a yasnippet snippet for adding the boilerplate to my "daily review" org document. Here's what it looks like: # key: ndr # name: newdailyreview # -- * Accomplishments :PROPERTIES: :CUSTOM_ID:...
1
vote
0answers
60 views

Define dummy variables from parameter list

Let's say I am experimenting with a codebase, and there's a function that takes a bunch of parameters, say void foobar(char A, char B, int m, float k, int n) I want to use the function somewhere, so ...
1
vote
1answer
111 views

Does yasnippet support alternative placeholders?

Consider sample below: SERVER-1 [connection] 192.168.0.1 success [connection] 192.168.0.2 failed [disconnect] 192.168.0.3 pending [connection] 192.168.0.4 success but [${1:connection}] ${2:192.168.0....
1
vote
0answers
67 views

Yasnippets gives an unclear error (with example snippet)

I have the following snippet for PHP-mode, called Public. #contributor : ReneFroger #name : snippet for public # -- # -------------------------------------------------- # Method f${2:name}. # -----...
1
vote
0answers
56 views

using re-search-forward in yas-snippet

I'm trying to develop a new yas-snippet for expanding a common c++ log function I use a lot. The first parameter to the LOG function can be guessed by searching for existing LOG calls in the buffer. ...
1
vote
0answers
52 views

Conflict between org and yas: \Cc &

In org mode, \Cc & goes back to the reference to a link; but this binding is suppressed by yasnippet. Do I have to redefine it, or can I prevent yasnippet from creating these bindings in the ...
1
vote
0answers
107 views

How to save a yasnippet placeholder's final value in an Elisp variable?

In its more recent versions, shell-script mode tailors its behavior in response to the sh-shell variable's value, which indicates the shell variant (zsh, bash, etc.) that the script is for. I've ...
1
vote
1answer
2k views

How to assign TAB to indentation and to yasnippet expand key

i'm trying to have the key TAB to: Indent my code (like in any other text editor) Trigger Yasnippet I have theses lines in my config: (global-set-key (kbd "TAB") 'yas-expand) (global-set-key (kbd "...
1
vote
1answer
338 views

Some yasnippets don't load anymore

I recently upgraded to yasnippet 0.10.0, on emacs 24.5.1/OS X and noticed that some of my yasnippets are not loaded anymore, but this only affects some. I can see that these are still in the compiled ...
1
vote
1answer
31 views

Yasnippet stops compile error highlighting

I have been compiling my C++ project using M-x compile which I like because it provides highlighted links to my errors: However after adding: (add-to-list 'load-path "~/.emacs.d/plugins/...
1
vote
1answer
224 views

yasnippet won't replace default values (placeholders) in org-table caption

I'm using yasnippet to create a template for org-mode tables. This works fine, and allows me to create default values (placeholders) for the column headers. The default values are highlighted by ...
1
vote
0answers
151 views

Triggering abbreviation expansion or auto completion automatically from a regular expression match?

With abbrev mode, I can define abbreviations that trigger when I type a certain term. For example, typing "yn" would be expanded to "Your Name". For this, "yn" must have been defined as an ...
1
vote
1answer
334 views

.yas-parents have no effect with web-mode

I'm using web-mode and yasnippet for coding PHP and HTML. To use yasnippet in web-mode, will have to install php-mode, php-auto-yasnippets, emmet-mode and ac-emmet as suggested in web-mode.org. But I ...
1
vote
0answers
315 views

Remove strange keybindings from YASnippet

I have YASnippet installed in emacs 24.5, which wasn't working and after a lot of different attempts at a fix, I now have the basics working, however - somewhere along the way - I have collected the ...
1
vote
1answer
936 views

yas-snippets not loading

While yas-snippet itself loads, the snippets do not. I tried loading them manually and using the following in my init, but neither loads any snippets. What could be the issue? (require 'yasnippet) (...
1
vote
0answers
550 views

Autocomple not working with yasnippet

I have configured yasnippet and auto-complete bindings so it won't collide, auto complete uses <tab> and yasnippet uses <backtab>: (add-to-list 'load-path "~/.emacs.d/plugins/...
1
vote
0answers
863 views

Company Completion Within Yasnippet Snippet

I am trying to use company-completion within a Yasnippet header. I bound company-complete to C-SPC and use that for my auto-completion. When I hit control enter, I get a screen like this: And I hit ...
0
votes
2answers
57 views

Is it possible to repeat the last org-mode source block's headers

Lately I have been writing a lot of literate sysadmining, writing down my thoughts as I explore systems by executing commands on them. This means that I end up writing the following boilerplate over ...