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.

107 questions
5
votes
1 answer

Trigger Key Not Working in Yasnippet emacs

Yasnippet seems to be working but the trigger key is not. I can load snippets, look at snippet tables and M-x yas/expand. However, after typing a trigger key (i.e time) I'd like to expand the snippet with the TAB key which isn't working. I…
akobre01
  • 777
  • 1
  • 10
  • 22
4
votes
0 answers

Org-Mode and Yasnippet with

In Emacs, how can I modify the org-mode keymap so that shift-tab runs yas-expand instead of org-shifttab? Better yet, how can I make it so that shift-tab only runs yas-expand when point is in front of a snippet trigger, and runs org-shifttab…
user3594595
4
votes
1 answer

How to quote $1 in yasnippet

Suppose, I have the following yasnippet: my $dir = __FILE__; $dir =~ s/(.*)\/.*/$1/; $1 here is the regular expression first match. Not yasnippet special symbol. How can I quote it, so it is inserted into the code as is?
user4035
  • 22,508
  • 11
  • 59
  • 94
4
votes
2 answers

Emacs lisp: evaluating list of strings

I am new to elisp but I am trying to spice up my .emacs a little. I am trying to define some paths, but having problems with creating a list of paths (and setting the list for YaSnippet more specifically). When I evaluate the list I get a list of…
BobuSumisu
  • 118
  • 1
  • 5
4
votes
1 answer

r-autoyas in Emacs

I am trying to get r-autoyas to work on Emacs 23.3.1 I have installed yasnippet and it works fine on its own. For eg: TAB after 'for' in c++ mode auto expands as it should. I then went on the get r-autoyas to work. I have followed the instructions…
Garnet
  • 107
  • 1
  • 1
  • 6
4
votes
1 answer

Show keybinding with yasnippet

I am setting up a new .emacs environment. But with my last setup, the yasnippet menu showed the keybinding. But now it doesn't. It seems very strange. I believe I have the latest version of yasnippet. If I try expanding via a keybinding I already…
Niclas Nilsson
  • 5,691
  • 3
  • 30
  • 43
3
votes
1 answer

How to show suggestions for YASnippets when using eglot

I'm currently using Emacs with eglot (minimal lsp client). However, no completions for snippets have appeared when I use the snippet library (e.g., YASnippet, tempel) together. Now I can specify the snippet name and expand it in the code. But I want…
3
votes
1 answer

How to use Yasnippet printf

I recently watched this fantastic video on how to use Yasnippet in Emacs. Can someone explain how to use this snippet? Specifically, what are the if and string-match elisp conditionals/functions doing in regards to the intended use of this…
Jordan
  • 73
  • 7
3
votes
1 answer

Positon cursor at a specified location in yasnippet

I have such a snippet # -*- mode: snippet -*- # name: test # key: test # condition: t # expand-env: ((yas/indent-line 'fixed) (yas/wrap-around-region 'nil)) # -- *** Expenses "" After insert this snippet to org doc, the cursor is positioned at…
AbstProcDo
  • 19,953
  • 19
  • 81
  • 138
3
votes
1 answer

Wrap text around a selection in emacs

I would like to wrap some text around selected text in emacs. From a selection of the lines: First item Second item I would like to get : \begin{itemize} \item First item \item Second item \end{itemize} Using C-c C-e in AucTeX collapses the…
user1031565
  • 107
  • 6
3
votes
1 answer

Emacs: how to create yasnippets for different RDBMs in sql-interactive-mode

I am using sql-interactive-mode to connect to 2 databases: MySQL and SQLite. I created yasnippets for mysql in yasnippets/sql-interactive-mode folder. For example to add a column in MySQL I use the following snippet: # -*- mode: snippet -*- # name:…
user4035
  • 22,508
  • 11
  • 59
  • 94
3
votes
3 answers

Configuring a Yasnippet for two scenarios -- (1) region is active; (2) region is not active

In conjunction with a user-configuration of (delete-selection-mode 1), is there a way to consolidate the two following Yasnippets into just one snippet so that it will work differently depending upon whether the region is active. For example: (if…
lawlist
  • 13,099
  • 3
  • 49
  • 158
3
votes
2 answers

Emacs: load only necessary yasnippets

Suppose, I have 2 subdirectories for yasnippets: ~/.emacs.d/yasnippets/perl-mode ~/.emacs.d/yasnippets/php-mode Currently I use the following code in my .emacs: (defvar *my-emacs-lib-dir* "~/.emacs.d/") (load (concat *my-emacs-lib-dir*…
user4035
  • 22,508
  • 11
  • 59
  • 94
3
votes
3 answers

Point existing YAsnippet mode to a new filetype

I am running through the Bottle tutorial, and the YAsnippet mode for HTML would get me a large share of the productivity bonuses I am used to when crafting Bottle template files (.tpl). Is there a way to tell YAsnippet to look at the existing…
yurisich
  • 6,991
  • 7
  • 42
  • 63
3
votes
1 answer

How to load yasnippets on condition

I am doing some Drupal programming and have created yasnippets for common functions: db_select, db_delete etc. I want to load them only when I am working on a Drupal file and not for a common php file. The task is this: given a list of yasnippet…
user4035
  • 22,508
  • 11
  • 59
  • 94