Skip to content

Instantly share code, notes, and snippets.

Created Jul 9, 2014
What would you like to do?
yasnippet for variable number of key-value pairs (concept shamefully stolen from
# -*- mode: snippet -*-
# name: keyvalue
# key: kv
# type: command
# --
(let ((yas-good-grace nil)
(count (* 2 (read-number "Number of elements: "))))
(concat "{\n"
(mapcar (lambda (num)
(format "${%d:key}: ${%d:value}" num (1+ num)))
(number-sequence 1 count 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment