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
0
votes
0answers
6 views

How to mark fields as non-expandable in yasnippet

How do I selectively mark snippet fields as being expandable or non-expandable? For example, I have a snippet # name: read in vector # key: cinvec # -- std::vector<${1:_type_}> ${2:_name_}(${...
1
vote
0answers
35 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
1answer
18 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 ...
2
votes
1answer
20 views

Font-lock Yasnippet template from within Org-Babel block

I want to manage my library of snippets from a single org-mode document and tangle these to their respective snippet files, as needed. Now functionally, this works out-of-the box, with the one ...
0
votes
0answers
11 views

Using yas-choose-value and a multi-level menu?

I am trying to finds some example code that uses YASnippet's yas-choose-value to display/select items from a GUI menu with sub-menus. My plan had been to use the popup-el package to implement this, ...
0
votes
0answers
13 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
33 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 ...
0
votes
2answers
38 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 ...
0
votes
0answers
27 views

yasnippet: problems with text-mode snippets

The snippets in the text-mode subdir are authomatically loaded when I use certain other modes (e.g. latex-mode, cc-mode, ess-mode, etc). There is any way to stop loading snippets of parents mode? ...
2
votes
3answers
57 views

YASnippet: Avoid electric pairs at expansion time

I am used to bind my YASnippet trigger keys to sequences that start with < (e.g. when I type <hn in org-mode, it expands to a custom header for my notes). The problem is that in some modes, the ...
1
vote
1answer
52 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
0answers
86 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
38 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
34 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 ...
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
495 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
35 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 ...
2
votes
1answer
58 views

Yasnippets: How to add if statements that check for regex?

I would like to replicate some of the snippets shown in this blog post Some of the snippets shown in that post involved if statements that check for regexp in snippet fields as well as checking for ...
1
vote
1answer
104 views

yasnippet not working on org

I created such a snippet $ cat snippets/diary_template # -*- mode: snippet -*- # name: diary template # key: dt # condition: t # -- **** Personal_Notes **** Personal_Tasks **** Project_Notes **...
0
votes
0answers
78 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
19 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
40 views

yasnippet color

I use yasnippet in orgmode to expand codeblocks of Python and start typing code. My snippet is defined as: # -*- mode: snippet -*- # name: emacs-jupyter code block for python (silent) # key: <spp #...
1
vote
1answer
119 views

Get autocomplete to display candidates only when tab is pressed

I've set up auto-complete on emacs to display completion candidates, and it seems to be working well so far. I'm finding the constant display (and changes in display) distracting when I type, and I ...
0
votes
1answer
41 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 ...
4
votes
1answer
99 views

sh-script-mode: get [[ … ]] pair expansion to automatically include whitespace?

Say you're coding a shell script and you want to write something like: if [[ "$out" =~ 'none' ]]; then return $err fi If you're just typing it out and have any of the various electric/pair ...
2
votes
1answer
158 views

Yasnippets for active web-mode engine

Say I have a snippets folder: snippets/web-mode/ ├── django │   ├── else │   ├── for │   └── if └── erb ├── else ├── for └── if Both engines have different syntax ({% %} and {{ }} vs <...
2
votes
1answer
58 views

How to tell YASnippet to ignore placeholder?

I have a shell script which uses an array to check dependencies. I'd like to make this into a YASnippet, but YAS recognizes the array value statement ${dependencies[@]} as a placeholder. How can I ...
0
votes
2answers
96 views

Problem with org-insert-link and yas-expand

I have a problem when I want to yas-expand a link in Org-mode and it has a dash (-) in the text (url and description). Then the snippet break and exits. If I do the same in fundamental-mode it works. ...
2
votes
2answers
138 views

Run function after specific snippet

I have a workflow that goes like, 1) use a snippet then 2) call a function. What a glorious opportunity to automate! But how? The snippet ipdb inserts import ipdb; ipdb.set_trace(). It has ...
1
vote
1answer
51 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:...
0
votes
0answers
155 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-...
1
vote
1answer
109 views

How to make yasnippet fall back to self-insertion when it shouldn't expand

I've decided to try out yasnippet recently, and while it seems to work for me, I have an issue with how it handles comments. I've set my trigger key to SPC, which causes unnecessary snippet expansion ...
3
votes
1answer
142 views

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?
1
vote
1answer
196 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 ...
0
votes
1answer
546 views

Best pratice advices for abbrev vs. completion vs. snippets

I am not sure if this is really a proper question but I am interested in having some opinions about the most efficient usage of Emacs' abbreviations features (abbrev/dabbrev) in combination with auto-...
0
votes
1answer
53 views

yasnippet: jump at the beginning of inserted snippet

Is it possible to define that after inserting a snippet, the cursor will jump at the beginning of what has been inserted? It will make it even more fun.
1
vote
1answer
95 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 ...
4
votes
1answer
253 views

Yasnippet: How to automatically advance to next field after `yas-choose-value`

Yasnippet has a function called yas-choose-value which is used like this: <div align="${2:$$(yas-choose-value '("right" "center" "left"))}"> $0 </div> How can I automatically exit the ...
2
votes
1answer
220 views

Yasnippet: How to create multiple snippet key bindings

I have a yasnippet with # binding: TAB f o o in the header. This is processed by the yasnippet library as 9 102 111 111. With respect to a keymap of a major-mode, both \C-i and (kbd "TAB") are ...
0
votes
1answer
77 views

Make yasnippet context sensitive

In LaTeX I often use pythontex in a way that there is a block \begin{pycode}[sessionname] ... \end{pycode} where I make some calculations. Then in the following text I refer to variables defined there ...
0
votes
2answers
143 views

Can't get automated c++ docstrings to work

I stumbled this thread and at first, it seems glorious, but I simply cannot get it to work. So when I try it on any program e.g.: #include <iostream> bool helloWorld(int a,int b){ dox<...
0
votes
1answer
191 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, })...
2
votes
0answers
149 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, ...
1
vote
0answers
51 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
208 views

How to insert leading spaces/tabs in yasnippet? [duplicate]

yasnippet does not respect spaces or tabs when they occur at the start a line. In my snippet file I have example which executes as example Escaping with \ doesn't work. How do I get leading ...
2
votes
0answers
774 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
139 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 ...
0
votes
2answers
125 views

Quick/electric text expansion

I've seen in some Emacs videos, the author would type #+BEGIN_SRC in their buffer, and emacs auto inserts #+END_SRC. Is this a feature I can "turn on" in vanilla Emacs? If not, which package can I ...
2
votes
1answer
441 views

Yasnippets: loading two major modes (`org-mode` and `LaTeX`)

I'm trying to load the yasnippets for the LaTeX mode every time I open an org file. Is it possible? How can this be achieved?
5
votes
1answer
193 views

Yasnippet expand snippet automatically instead of prompting possible completions

I have two snippets: e[TAB] expands to $ $1 $ $0 ($1 and $0 are placeholders); emph expands to \emph{$0} ($0 is a placeholder, this is a default snippet I suppose) I'm writing a lot of equations ...