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
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
1answer
229 views

Why is this snippet working properly, and not here?

I stumbled upon this feature for functions, and was eager to try it out. However, I ran into an error message, after trying the snippet in python-mode: [yas] elisp error: Symbol’s value as variable ...
1
vote
1answer
317 views

Can I create a yasnippet with a repeating variable length list

Javascript Angular has a peculiar pattern for creating controllers that looks like this: myApp.controller('myController', ['$scope', 'foo', 'bar', function($scope, foo, bar) { ...
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 ...
1
vote
1answer
211 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 ...
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: ...
2
votes
1answer
143 views

Yank during yas-expand without aborting expansion

When expanding a yasnippet snippet and filling out completion fields yanking/pasting inserts text correctly among fields as expected, but interrupts the snippet expansion behavior (as if pressing C-g /...
1
vote
1answer
161 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?...
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 ...
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....
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
1answer
114 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"...
3
votes
1answer
124 views

Fill-column conflicts with YASnippet [Examples in gif]

I use fill-column in my dot-Emacs. And I have the following setting: (turn-on-auto-fill) (set-fill-column 60) The result looks like this: Every time when the input exceeds columnnumber 60, it will ...
1
vote
1answer
195 views

How to get the class name?

I'm trying to devise a function which returns the class name. I would like to call that function inside a Yasnippet snippet for PHP-mode, so the class name will be inserted inside the template snippet....
1
vote
1answer
286 views

How mirror another line in Yasnippet?

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

Disable default Yasnippet snippets?

How do I disable all pre-existing yasnippet snippets? I only want to use ones that I define myself.
3
votes
2answers
492 views

Org-mode: any keyboard shortcut for Latex code?

On p.33 of the Org-guide Carsten Dominek writes you can use #+LATEX: and #+BEGIN_LATEX ... #+END_LATEX construct to add verbatim LATEX code Is there a keyboard combination or default snippet that ...
0
votes
0answers
21 views

Yasnippet with CEDET [duplicate]

I used to launch yasnippet just with c-mode with a hook in my .emacs but after adding some code to use CEDET and ECB yasnippet doesn't run automatically. I guess some modes may have been overwritten ...
5
votes
1answer
120 views

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 ...
2
votes
1answer
77 views

how to make yasnippet case insensitive

I want yasnippet to expand both "Cp" and "cp" into the same, say, "\citep{}". How can this be done? Is there a way to make yasnippet case insensitive? As a quick-and-dirty solution, I tried ...
1
vote
1answer
315 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 ...
5
votes
2answers
420 views

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 ...
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
1answer
781 views

How to install/setup yasnippet for buffer-local usage?

The instructions for installing yasnippet globally are set forth in the Github README.mdown -- https://github.com/capitaomorte/yasnippet -- and also in the comments at the top of yasnippet.el library. ...
2
votes
1answer
814 views

in yasnippet, how to insert variable date with fixed time of day?

I want a yasnippet to insert an org-mode date and time. The date should be today's date, but the time should be fixed. So far my snippet correctly inserts today's date, but not the time: # -*- ...
1
vote
0answers
278 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
votes
1answer
387 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 ...
2
votes
1answer
947 views

disable TAB in company-mode

I'm trying to get several plugins all playing nicely: yasnippet, company-mode and ENSIME. I'm aware of How to make yasnippet and company work nicer? but I was thinking about another, simpler, ...
0
votes
2answers
256 views

Mirror with character replacement in yasnippet

I would like to do 2 things: first mirror a field and replace spaces with "-". If nothing is typed in the field, junto to the mirror. The code is: \begin{theorem}[$1] \label{thm-${1:$( ???? )}} $0 ...
0
votes
1answer
116 views

Why does a theme change cause reloading - YASnippet

The problem: Before installing YASnippet changing themes was instantaneous, now it YASnippet reloads itself in someway making changes take a few seconds. Is this functionality necessary? Can I turn ...
1
vote
1answer
109 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
790 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) (...
5
votes
2answers
423 views

What templates are available for generating an elisp library?

At some point I remember encountering a command that generated a skeleton of a properly formatted emacs-lisp library as below: ;;; library.el --- summary ;; Copyright ... ;; Author: ;; Keywords: ;;...
1
vote
2answers
599 views

Yasnippet invoked org-time-stamp function inserts double timestamp

I created a yasnippet template to quickly timestamp a note I'd like to make in org-mode. The body of the yasnippet file reads $0 :PROPERTIES: :CREATED: `(org-insert-time-stamp nil t t)` :END: ...
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/...
4
votes
1answer
760 views

abbrev vs yasnippet for this use case

I have not done much with abbrev-mode or yasnippet, but I recently started using AucTex mode with great success, and I think some common TeX markup I'm inputting could benefit from expansion. Example:...
3
votes
2answers
3k views

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 ...
0
votes
1answer
431 views

How start a new line in Yasnippet, with the comment?

Q: how do I get yasnippet to insert the comment sign, when I press return to start new line? For example, my snippet looks like this ;; $1 . ;; / END $2 When the cursor ...
4
votes
1answer
798 views

How bind keys to a specific snippet in yasnippet folder?

Let's say I have a yasnippet snippet called foobar and I have configured it to work it with company-mode (which is not relevant here). Now each time I needed to type foobar I would select it from ...
2
votes
1answer
2k views

Indent each yasnippet line according to major mode

I want to use yasnippets to generate control flow statements in Lua. -- a control flow statement in Lua if foo then return "foo" elseif bar then return "bar" else return "baz" end First I ...
13
votes
1answer
2k views

One yasnippet snippet for multiple modes

I have the following snippet: # -*- mode: snippet -*- # contributor: Song Qiang <tsiangsung@gmail.com> # key: m # group: Math # name: Inline math \( ... \) # -- \\($1\\)$0 and I want it to be ...
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
1answer
919 views

Yasnippet - No snippet tables active/ YASnippet tables empty

In .emacs, I bound the key for yasnippet as, (define-key yas-minor-mode-map (kbd "C-SPC") 'yas-expand) In a buffer with python as major mode and yasnippet, autocomplete as minor mode, yasnippet ...
3
votes
1answer
635 views

How configure keybinding for Yasnippet only?

When you insert a snippet from Yasnippet, you have this, for example # -------------------------------------------------------------- # $1 (`(insert-date)`) # ----------------------------------------...
3
votes
1answer
539 views

Yasnippet doesn't work when tab-always-indent set to true

It annoys, when autocompletion & indentation both gets called on TAB press. So, i configured to use TAB key only for indentation as, (setq tab-always-indent t) Now, when i enable yas-minor-mode ...
0
votes
2answers
2k views

Configuring yasnippet and autocomplete to work with C/C++ headers

My computer system and set up are OS: Arch Linux 64bit emacs version: 24.4 alias emacs='emacsclient -t -s server --alternate-editor=' Update: auto complete is working with yasnippet occasionally ...
4
votes
1answer
566 views

yasnippet configuration does not persist across emacs runs

yasnippet does not complete snippets that I add to yas/root-directory (typing the key and hitting tab does not complete). If I remove .yas-compiled-snippets.el from an affected directory, then run ...
13
votes
1answer
5k views

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 ...
1
vote
1answer
283 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 ...
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;...