views:

48

answers:

1

I use viper-mode in emacs, but I want to use YASnippet as well. However, when I enable viper-mode and try using tab-completion through YASnippet, nothing happens. How do I get the two of them to work together?

+1  A: 

Using an Emacs without any customizations (emacs -q), I got the following to work:

(load-file "c:/cygwin/home/Trey/scratch/yasnippet-bundle.el")
M-x viper-mode
(define-key viper-insert-global-user-map (kbd "<tab>") 'yas/expand)
C-x C-f a.cpp
i
main<TAB>

Try that, see if it works (as in, if there's something in your .emacs that's messing things up). Also, check to see what Emacs thinks your TAB key is. On my windows system, the tab key was bound to <tab> and not TAB - try doing M-x describe-key TAB and see what the *Help* buffer translates it to. yasnippet appears to bind to TAB, so I needed the extra binding for <tab> to get things to work.

For more information about how Emacs handles the TAB, read the documentation for function keys.

Trey Jackson
Perfect, that worked to make viper-mode and YASnippet work together. The only thing is that now, when I press `TAB` to actually insert a tab, it just inserts a space. How can I make it insert a tab when it's not invoking YASnippet to do a completion?
Chetan
Correction, it's actually inserting a weird character, not even a space. How do I fix this?
Chetan