12

I just moved to spacemacs from vim and am a complete newbie with emacs.

I cannot figure out how to expand yasnippets while in evil-insert-mode. I know yasnippet is available because I can choose from the available snippets using Spc i s. However I'd like to be able to <Tab> expand them. What am I missing?

4
  • Have you tried company-mode? I think it is very handy when dealing with auto completion---it has many different backends, and yasnippet is one of them.
    – xuhdev
    Apr 6, 2016 at 20:15
  • yeah, spacemacs comes bundled with auto-complete and company-mode. I'm not sure which one is in effect and not really sure how to find out.
    – owise1
    Apr 6, 2016 at 21:31
  • Use describe-mode (it's on <f1> m in default Emacs), and search in 1st paragraph (where it says "Enabled minor modes: ...").
    – npostavs
    Apr 7, 2016 at 14:46
  • thanks! it says company is enabled and yas. strangely I dont see company-mode's dropdown box with suggestions when I type and the yassnippets dont expand
    – owise1
    Apr 7, 2016 at 15:58

3 Answers 3

13

M-/ is the default binding to expand snippets not TAB. You can find this out with Spc ? then searching for yas

5
  • I have a stupid question - what does M-/ mean? :)
    – aikeru
    Nov 14, 2016 at 0:59
  • 1
    @aikeru not stupid. it means {option} + /
    – owise1
    Nov 14, 2016 at 17:18
  • so M is the ALT key on, say, a Linux or Windows machine, right?
    – aikeru
    Nov 14, 2016 at 17:33
  • 1
    I think so yes.
    – owise1
    Nov 14, 2016 at 18:16
  • Should I remap yas-expand to TAB or not? There must be a good reason not to since that's the default, but I'm not understanding it. If I should remap, is there an option for this in Spacemacs?
    – Heisenberg
    Mar 25, 2018 at 1:51
3

M-x yas-expand, you can C-h f yas-expand to check which hotkey is assigned.

company is an auto-completion framework which supports many backends. company-yasnippet could be its backend. If you use company-yasnippet, please check https://github.com/company-mode/company-mode/issues/492

I use yasnippets independently and assign global hotkey M-j to yas-expand

0

As I can see Spacemacs is not using the classic yas-expand but uses hippie expand which triggers yas-expand:

M-/ runs the command hippie-expand (found in global-map), which is an
interactive autoloaded compiled Lisp function in ‘hippie-exp.el’.

 is bound to M-/.

(hippie-expand ARG)

:around advice: ‘ad-Advice-hippie-expand’

Try to expand text before point, using multiple methods.
The expansion functions in ‘hippie-expand-try-functions-list’ are
tried in order, until a possible expansion is found.  Repeated
application of ‘hippie-expand’ inserts successively possible
expansions.
With a positive numeric argument, jumps directly to the ARG next
function in this list.  With a negative argument or just SPC u,
undoes the expansion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.