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.
237 questions
1
vote
1
answer
2k
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
2
answers
700
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:
;;...
2
votes
2
answers
1k
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
0
answers
640
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
1
answer
1k
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:...
8
votes
3
answers
5k
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 ...
1
vote
1
answer
908
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
1
answer
1k
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 ...
5
votes
1
answer
3k
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 ...
18
votes
2
answers
3k
views
One yasnippet snippet for multiple modes
I have the following snippet:
# -*- mode: snippet -*-
# contributor: Song Qiang <[email protected]>
# key: m
# group: Math
# name: Inline math \( ... \)
# --
\\($1\\)$0
and I want it to be ...
3
votes
0
answers
259
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
1
answer
2k
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
1
answer
912
views
How configure keybinding for Yasnippet only?
When you insert a snippet from Yasnippet, you have this, for example
# --------------------------------------------------------------
# $1 (`(insert-date)`)
# ----------------------------------------...
3
votes
1
answer
809
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
2
answers
3k
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 ...
5
votes
1
answer
913
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 ...
20
votes
1
answer
9k
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
1
answer
353
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
0
answers
176
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;...
3
votes
2
answers
351
views
Org-mode: Disable `t` + `TAB` => `# TODO: ` autocomplete feature
There is a built-in org-mode shortcut where a t character followed by TAB key results in an auto-complete function that produces the # TODO: string literal. How can I disable this? Even better, how ...
9
votes
1
answer
5k
views
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, ...
1
vote
1
answer
193
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 ...
12
votes
2
answers
3k
views
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:
/**
* <Insert description of importantStuff>
*
* @...
4
votes
0
answers
294
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 ...
27
votes
2
answers
11k
views
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 ...
1
vote
0
answers
1k
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 ...
4
votes
1
answer
453
views
How can I disable an individual snippet when in shell-script-mode?
I'm a fairly extensive user of YAsnippet but there is an annoying niggle when I'm working on shell scripts. The default prog-mode snippets includes "fi" which expands to FIXME. This would be fie but ...
6
votes
1
answer
1k
views
(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, ...
3
votes
4
answers
1k
views
Autocomplete environments like in TeXStudio
TeXStudio autocompletes environments. How can I get AUCTeX to do the same?
I can begin typing an environment name (say myenvironment) and, after entering a part of it (my, myenv, etc.), I hit ...
4
votes
3
answers
1k
views
Creating a custom Yasnippet with conditions
I have a yasnippet that is conflicting with multiple-cursors because it is not exiting immediately. When multiple-cursors is not active, I would like the snippet to pause and permit me to enter the ...
3
votes
1
answer
465
views
Yasnippet prompt when using commands interactively?
How can I use yasnippet to invoke LaTeX commands interactively?
If I use auctex to insert \usepackage it starts a minibuffer which lets me select the desired package (including tab completion). ...
4
votes
1
answer
1k
views
Is there something I should do about "package assoc is obsolete" message?
Just noticed this message after emacs startup "Package assoc is obsolete!", but everything seems to work nice. The requirement seems to be called by yasnippet only.
I just want to know if I should ...
2
votes
0
answers
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 ...
8
votes
1
answer
765
views
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 ...
6
votes
2
answers
710
views
YASnippet: How to resume (or reactivate) snippets after exiting them
After exiting yasnippet snippets that contain one or more tab stops, I often find myself wanting to go back and modify content that I entered at the tab stops. Of course, I can do this using standard ...
6
votes
1
answer
886
views
Auto-Complete stops working with C files
I am using Emacs24, and my auto-complete plugin was working when I opened my .emacs file. However, it doesn't work when I open some file like :
whatever.c
To add to this, the auto-complete-c-...
9
votes
1
answer
2k
views
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 ...