Display all snippets of yasnippet
Asked Answered
S

5

34

What's a nice way to display all snippets available to yasnippet to the current major mode?

Sherwin answered 14/4, 2012 at 16:19 Comment(0)
G
44

this command shows the snippets and keys

 m-x yas/describe-tables
Gameto answered 14/4, 2012 at 18:5 Comment(3)
@Tass please update your yas package github.com/capitaomorte/yasnippet/downloadsGameto
FYI in 2020 yasnippet has a new home - github.com/joaotavora/yasnippetSheets
GOTHA: this show all snippets for the current active mode. So not all available snippets for all modes. I know this was the original question, however I'm just posting this as a comment since I know I might make the same mistake twice.Simonsimona
S
16

yas/describe-tables is an alias for yas-describe-tables in yasnippet.el.

(yas/describe-tables &optional CHOOSE)

This function is obsolete since yasnippet 0.8;

use yas-describe-tables instead.

Display snippets for each table.

Skatole answered 24/7, 2014 at 10:55 Comment(0)
E
6

Are you looking for M-x yas/insert-snippet? It will list all available snippets and you can choose one of them to insert.

Exhaustless answered 14/4, 2012 at 17:43 Comment(0)
F
5
(defvar lawlist-context-menu-map
  (let ((map (make-sparse-keymap "Context Menu")))
    (define-key map [help-for-help] (cons "Help" 'help-for-help))
    (define-key map [seperator-two] '(menu-item "--"))
    (define-key map [my-menu] (cons "LAWLIST" (make-sparse-keymap "My Menu")))
    (define-key map [my-menu 01] (cons "Next Line" 'next-line))
    (define-key map [my-menu 02] (cons "Previous Line" 'previous-line))
    (define-key map [seperator-one] '(menu-item "--"))
  map) "Keymap for the LAWLIST context menu.")

(defun lawlist-popup-context-menu  (event &optional prefix)
  "Popup a context menu."
  (interactive "@e \nP")
    (define-key lawlist-context-menu-map [lawlist-major-mode-menu]
      `(menu-item ,(symbol-name major-mode)
        ,(mouse-menu-major-mode-map) :visible t))
    (define-key lawlist-context-menu-map (vector major-mode)
      `(menu-item ,(concat "YAS " (symbol-name major-mode))
        ,(gethash major-mode yas--menu-table)
          :visible (yas--show-menu-p ',major-mode)))
    (popup-menu lawlist-context-menu-map event prefix))

(global-set-key [mouse-3] 'lawlist-popup-context-menu)

Example:

Fragonard answered 24/7, 2014 at 18:10 Comment(0)
E
2

If you are using company mode for autocompletion you can also call company-yasnippet to show all available snippets in the company interface.

Screenshot showing the available yasnippets through the company interface

Event answered 11/10, 2022 at 0:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.