Emacs Tip for YASnippet: Expand Input with Hyphen

Perm url with updates: http://xahlee.org/emacs/emacs_tip_yasnippet_expand_whole_hyphenated_word.html

Emacs YASnippet Tip: Expand Whole hyphenated-word as Input

Xah Lee, 2011-07-29

Emacs Tip for YASnippet: Expand Whole hyphenated-word as Input

In YASNippet, you can define your own templates. For example:

(buffer-substring-no-properties START▮ END)

But sometimes your word contains a hyphen, but upon expansion, it uses only part of the word as input. For example, you want:

(buffer-substring START▮ END)

But you get:

buffer-(substring STRING▮ FROM &optional TO)

How to fix this?

Put the following in your init file:

;; 2011-07-29 yasnippet. Make the “yas/minor-mode”'s expansion behavior to take input word including hyphen.
(setq yas/key-syntaxes '("w_" "w_." "^ ")) ; default is '("w" "w_" "w_." "^ ") as of 2011-07-29

Thanks to João Távora. Source groups.google.com.

Popular posts from this blog

11 Years of Writing About Emacs

does md5 creates more randomness?

Google Code shutting down, future of ErgoEmacs