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.
Questions tagged [yasnippet]
107 questions
2
votes
2 answers
Conflicts between org-mode and yasnippet
EDIT My issue was related to snippet syntax all along... The configuration below totally works.
I'm trying to use org-mode and yasnippet together and it's not working even with some of the workarounds on the org-mode FAQ. Whenever I hit TAB on a…

mgalgs
- 15,671
- 11
- 61
- 74
2
votes
1 answer
Emacs yasnippet - insert snippet on keystroke
Is there a way to easily insert a snippet when a certain keybinding is activated? AFAICT, official documentation suggests setting: #binding: directive, smth like this:
#name :
...
#binding: C-c C-c C-m # --`(when yas/prefix…

aL3xa
- 35,415
- 18
- 79
- 112
2
votes
1 answer
Adding a custom yasnippet directory to `Spacemacs`
Sorry for the very newb question, but was just trying to configure a separate directory for yasnippets in spacemacs. I am not familar with emacs lisp at all. So it says that I can put the directory in
(setq-default dotspacemacs-configuration-layers…

krishnab
- 9,270
- 12
- 66
- 123
2
votes
0 answers
Get real string length in emacs
What is the proper way to compute the actual string length in emacs? By actual I mean I want the number of chars inserted into a buffer after doing something like (insert "\nhi") or (insert "\x100").
For example, I have a snippet for writing…

Rorschach
- 31,301
- 5
- 78
- 129
2
votes
0 answers
How to specify order of how snippets are shown in YASnippet's prompt menu?
When writing snippets for YASnippet, is it possible to specify how snippets should be displayed in the prompt menu ("Choose a snippet: ..")?
For the sake of user friendliness, I would like the prompt menu to look like the Emacs YASnippet…

Øyvind Eidhammer
- 21
- 3
2
votes
0 answers
Define a function for yasnippet
I've got a yasnippet for creating a subsection banner comment in c style code:
# -*- mode: snippet -*-
# name: Subsection Comment Block
# key: comm-subsec
# --
/*${1:$(make-string (floor (/ (- fill-column 8 (string-width yas-text)) 2.0)) ?\=)} …

aaron.cimolini
- 123
- 1
- 6
2
votes
1 answer
Is it possible to use "place holder" in values of "yas-choose-value"?
In emacs yas-minor-mode, I want to use place-holders in values listed in yas-choose-value.
Is it possible?
Following code is what I want to do.
However it doesn't work well..
# -*- mode: snippet -*-
# name: my_func
# key: my_func
#…

elgoog
- 77
- 5
2
votes
1 answer
Is it possible to make autocomplete to complete a yasnippet in Emacs?
I have configured yasnippet and auto-complete bindings so it won't collide, auto complete uses and yasnippet uses :
(add-to-list 'load-path
"~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)
;;…

Fabman
- 333
- 5
- 20
2
votes
1 answer
generate comments for function by emacs
The function :
function show($string = "hi") {
echo $string;
}
I need the comments like:
/**
* @brief
*
* @param $string
*
* @returns
*/
function show($string = "hi") {
echo $string;
}
Can I generate comments like this by yasnippet?
In…

bloody numen
- 487
- 6
- 13
2
votes
1 answer
How to never expand yasnippets in comments and strings
I'd like to disable YASnippet expansion (for example, if) in comments and strings, but don't find how to do that in a generic way.
On The condition system, they say how to do it for Python, but I'd like to get it working for all prog-modes at once,…

user3341592
- 1,419
- 1
- 17
- 36
2
votes
1 answer
Javascript environment in emacs
I have been trying to start with emacs for doing node.js based project development.
I have not been able to set up my emacs for this. It has more become like a trial and error kind of black box leading to frustation. Can you help me in setting this…

Ashish Negi
- 5,193
- 8
- 51
- 95
2
votes
1 answer
yasnippet how to debug?
I'm using some snippet I found from the internet.
And I encounter lots of error when using them.
for example,
printf ("${1:%s}\\n"${1:$(if (string-match "%" text) "," "\);")
}$2${1:$(if (string-match "%" text) "\);" "")}
This is a printf snippet…

LoveProgramming
- 2,121
- 3
- 18
- 25
2
votes
1 answer
Argument names using r-autoyas
I've recently been using r-autoyas (0.28) when working in R scripts (emacs 24.3.1, ESS 13.09-1, Windows 8.1) and have found it really helpful. It works out-of-box on loaded R libraries and user-defined functions after setting (setq…

Cole Monnahan
- 57
- 3
2
votes
2 answers
How to make auto-complete work with yasnippet and abbrev?
I want Emacs to work like this:
Let auto-complete auto-popup menu:
(setq ac-auto-show-menu 0.8)
(setq ac-delay 0.1)
Use C-n/p / M-n/p to select auto-complete popup menu candidates:
(define-key ac-menu-map (kbd "M-n") 'ac-next)
(define-key…

stardiviner
- 1,090
- 1
- 22
- 33
2
votes
1 answer
How to select a region with a leading \$, and surround it with a yasnippet
Could anyone please suggest a method to surround a region that contains a leading \$ and surround it with a snippet. In latex-mode, I am frequently underlining or double-underlining monies due and the yasnippet being used removes the backslash. …

lawlist
- 13,099
- 3
- 49
- 158