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
1
vote
1 answer
Latex snippet associate with Rnw mode in Emacs
I would like to have my yasnippets for Latex mode to be available for .Rnw files. How to go about this? Also, it would be nice to have R snippets available as well.
EDIT:
I found out the real problem is that in .Rnw the TAB key is bound not to…

PascalVKooten
- 20,643
- 17
- 103
- 160
1
vote
2 answers
How do I write a YASnippet that expands into a Java package declaration according to the buffer's directory?
Files that define Java classes can be organized into packages by declaring them to belong to particular package, e.g.
package foo.bar;
which declares that the file in question belongs to the subpackage bar of the package foo. The files are then…

N.N.
- 8,336
- 12
- 54
- 94
1
vote
1 answer
Emacs yasnippet mirroring/transformation
I wrote this snippet to insert a new variable into Java source:
# -*- mode: snippet -*-
# name: variable
# key: v
# --
$1 ${1:$(java-default-variable-name text)} = new $1($2);
$0
It declares and creates a variable based on the type,…

abo-abo
- 20,038
- 3
- 50
- 71
1
vote
2 answers
Emacs Display Effects with Yasnippet
Yasnippet has a nice "run ... after exiting a snippet".
What I would like to do is include some visual effect after each ending snippet (changing background color for, say a second, or more sophisticated stuff).
I did this by switching background…

PascalVKooten
- 20,643
- 17
- 103
- 160
1
vote
1 answer
Rope and Yasnippet in Emacs
I setup python support for emacs using rope and yasnippet by following the tutorial given at http://www.enigmacurry.com/2009/01/21/autocompleteel-python-code-completion-in-emacs/#disqus_thread.
I declared a string variable a_str="Hello". Now when i…

Kris
- 1,403
- 3
- 17
- 26
0
votes
1 answer
Disable auto completion of python code in emacs with elpy
I am new to using elpy, an emacs package for working with Python. I am not a fan of auto-complete in general, and the YAsnippet tool elpy uses in particular. How can I disable it? I found on the web I should do (delete 'elpy-module-yasnippet…

D Strozzi
- 150
- 1
- 11
0
votes
0 answers
How to expand yasnippet in different part of buffer
Question is simple:
Is there any way how yasnippet can be triggered at one place in the buffer, and executed in another place of the buffer, while returning to original position at the end of expand?
Typical situation is e.g. when coding Verilog…

David Belohrad
- 458
- 5
- 19
0
votes
1 answer
Snippet for title in restructured text in vs code
In restructured text, titles are written with equal number of nonalphanumeric 7-bit ASCII
character as the title text. The underline and overline if both used, should be equal and at least as long as title text. From the official docs:
Titles are…

Suman Khanal
- 3,079
- 1
- 17
- 29
0
votes
1 answer
YASnippet conditional activation based on buffer/file name
I have a bunch of YASnippet for a single mode and sometimes it's kind of hard to find the snippet I'm looking for in the main list.
Expected behavior:
My goal is to have snippets like this one activated in all files/buffers with "model" in its…

BinaryButterfly
- 18,137
- 13
- 50
- 91
0
votes
0 answers
Change the size of width in yas-describle-table
Upon checking yas-describe-table, I find
state name key
#+ATTR_HTML: :width .. width
Click into it
# -*- mode: snippet -*-
# name: #+ATTR_HTML: :width ...
# --
#+ATTR_HTML: :width ${1:500px}
I…

AbstProcDo
- 19,953
- 19
- 81
- 138
0
votes
1 answer
yasnippet insert the current date
I tried to create a template which insert a transaction with the current date
# -*- mode: snippet -*-
# name: breakfast
# key: breakfast
# condition: t
# --
2019-09-05 * ""
Assets:DebtWechat CNY
…

AbstProcDo
- 19,953
- 19
- 81
- 138
0
votes
1 answer
In Emacs how can I use YASnippet to automatically add entry and Clock-in for this entry?
I am trying to create an automation script
such the following steps will happen:
Automatically load my DailyPlan.org file.
For current Date entry.
Insert a new YASnippet subtask entry.
If there is a task being clocked Pause it else ignore.
Start…

drgeb
- 11
- 1
- 3
0
votes
1 answer
How to expand the key before which there is a non-key string?
For example, this is my snippet in python mode:
# -*- mode: snippet -*-
# name: (
# key: (
# --
($0)
I can expand (to (), but I can not expand a( to a().
How to expand a( to a()?

Big Shield
- 612
- 5
- 15
0
votes
1 answer
How to insert "n" org-mode checkboxes interactively (with yasnippets or else)?
To organize reading tasks, I use org-mode checkboxes in the following way:
* TODO author, book_title [3/12]
- [X] chapter_01
- [X] chapter_02
- [X] chapter_03
...
- [ ] chapter_12
Since it is tedious to write this up for every book, I was…
0
votes
1 answer
Dynamic YASnippet, inserting method name and arguments
How is it possible to access the name of the method (and its arguments) when inserting a YASnippet in a Java (or JavaScript) code block?
The goal is to be able to expand
logm
into (for example):
log("notify() called with: " + "context = [" +…

user3341592
- 1,419
- 1
- 17
- 36