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.

39 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
129 views

Conditionally remove parts of a snippet when the corresponding input field is left empty?

When writing LaTeX code I use a snippet that expands begin to the following \begin{$1} \label{$1:$2} $0 \end{$1} This suits most of my purposes well, since I use labels rather systematically....
4
votes
0answers
184 views

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 ...
3
votes
0answers
61 views

Preferring org-cycle to yas-expand when hitting tab

If both org-mode and yasnippet are active, tab will expand a snippet if possible and otherwise execute org-cycle. Is it possible to reverse this priority? org mode version: 9.0.9. yasnippet version: ...
3
votes
0answers
58 views

Can I move imports to top of file from yasnippet using elisp code?

I want to add import statements in my yasnippets that go the top of the file (where they will be automatically sorted (or removed if the import already exists)). from subprocess import call # I want ...
3
votes
0answers
144 views

Jump sequence for placeholders in yasnippet not working in org-property blocks

I use the yasnippet bundle and it works like charm. When I want to include placeholders in a PROPERTIES section of an org-document it is not working. Here's the snipper: #type: snippet # -- :...
2
votes
0answers
134 views

Aligning (ditaa) rectangles with variable string width in yasnippet

To quickly add simple diagrams to notes, I've created yasnippets for ditaa boxes. The text inside each box is a $x - and therefore has a length I do not know at snippet design time. As a consequence, ...
2
votes
0answers
709 views

In Spacemacs, how can I enable snippets without having an autocomplete popup/completion?

I'm using the auto-completion layer in Spacemacs with the following configuration: (auto-completion :variables auto-completion-return-key-behavior nil auto-...
2
votes
0answers
118 views

How to get a global available yasnippet snippet?

How to create a yasnippet snippet which is available in all modes? Lets say I have a function which evaluates the sexpr before the cursor and replaces is with its value, Link to code. Also I caught me ...
2
votes
0answers
126 views

Set a field in yasnippet to edit/modify rather than replace default contents

I'm curious if it's possible to define a yasnippet completion field with a default value specified to initially edit/modify the value rather than replace it. For this elementary example: ${1:...
2
votes
0answers
671 views

Web-Mode + Yasnippets + Autocomplete, error before create-php-snippet

I am trying to use auto-complete + php-auto-yasnippets with web-mode, but I can't get the snippets to work correctly. If I start typing imp, I correctly get auto-completion to implode but if I press ...
2
votes
0answers
1k views

Stop Yasnippet from autoloading

Is there a way to stop Yasnippet from autoloading? I installed it from melpa (v.20141102.1554), and have no reference to it in my init files. However, keeps up autoloading whenever I run emacs. I only ...
1
vote
0answers
28 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
47 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
0answers
58 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
53 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
47 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
94 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
0answers
138 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
0answers
276 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
0answers
468 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
726 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
0answers
47 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-...
0
votes
0answers
30 views

Unable to use yasnippet with Emacs on Mac or Windows

I've been trying to make yasnippet work with my Emacs on Mac OS 10.15 and Windows 10 but have failed till now. Along with a few other routes that I took, below is one of them: Install the package ...
0
votes
0answers
33 views

`ALT-<return>` breaks ya-snippet

I have a short snippet template which I use to document my patient’s encounter in org-mode. It consists of * Subjective $1 * Objective - Examination: $2 - Investigations seem : $3 * Assessment ...
0
votes
0answers
211 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 ...
0
votes
0answers
32 views

prevent yas from inserting a new-line after expansion

So I'm doing a recursive snippet with yas $>name: "${2:`(file-name-nondirectory (file-name-sans-extension (buffer-file-name)))`}"${3:, $>np}$0 but yas inserts a new-line at the end of every ...
0
votes
0answers
55 views

spacemacs: show yasnippets at top of completion popup list

yasnippet can be integrated into auto-compltion in spacemacs. I want to show snippets at the top of the auto-completions list. Default is at bottom. foo_______________ |foo -> foo snippet| |foo ...
0
votes
0answers
16 views

Find files interactively with a yassnippet with helm-find-files?

I've seen the answers to this question on inserting filenames interactively within a yasnippet. They are excellent and work great. I was wondering, however, if it's possible to expand them to use the ...
0
votes
1answer
34 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 ...
0
votes
0answers
34 views

yasnippet in f90 mode

I'm using autocomplete and yasnippet, therefore I added (define-key yas-minor-mode-map (kbd "<tab>") nil) (define-key yas-minor-mode-map (kbd "TAB") nil) (define-key yas-minor-mode-map (kbd "&...
0
votes
0answers
129 views

Whats the recommended way to install yasnippet for an emacs prelude user?

Is doing mkdir ~/.emacs.d/personal/snippets/ the correct way and putting snippets there? I've been reading https://github.com/bbatsov/prelude/issues/98 What I did: ;; personal.el (prelude-require-...
0
votes
1answer
165 views

Capitalize word as you type in emacs/spacemacs (YAS snippet)

Trying the following yas snippet # -*- mode: snippet -*- #name : vuex-action #key : va # -- [${1:$$(capitalize-word yas-text)}]: ({ commit, dispatch, getters, }, { $2, }) => { commit($1, { $2, })...
0
votes
0answers
162 views

yasnippet doesn't work on Windows

I installed Emacs 25.1.2 on Windows 10 machine, then installed yasnippet library from Elpa. Copied all my snippets from Linux machine. But for some reason none of them work. When I open a file I get ...
0
votes
0answers
42 views

yasnippet, “Wrong number of arguments” when in X11 window

Using yasnippet, whenever I use the yas-expand function to expand a snippet, the result depends on whether the emacs session is in an X window or not. If I am in an in-terminal session of emacs, then ...
0
votes
1answer
1k 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 "...
0
votes
0answers
52 views

A problem of first line of yasnippet

My yasnippet version is 0.8.0 and emacs is 25.0.50 I want to add a default value And I use following code. # -*- mode: snippet; require-final-newline: nil -*- # name: matrix # key: y_ma # binding: ...
0
votes
0answers
115 views

Need help with a snippet

Can someone help me with this snippet? I found it here # -*- mode: snippet -*- # name: jsdoc comment # key: doc # -- /** * $0 `(save-excursion (let* ((pos-fun (re-search-forward "\\<function\\s-*(...
0
votes
0answers
101 views

how to suppress elisp evaluation output in yasnippet?

I'm trying to write a yasnippet template to write a standard header at the top of files. I have (goto-char (point-min)) at the beginning of the template in order to move point to the top of the buffer;...
-1
votes
1answer
386 views

yasnippet doesn't recognize $0 placeholder, why?

My emacs is running on Window 7 and I have just installed yasnippet via M-x package-list and added few lines to my .emacs file because I read around the web that it needs to be initialized. I tried ...