When you insert a snippet from Yasnippet, you have this, for example

# --------------------------------------------------------------
# $1 (`(insert-date)`)
# --------------------------------------------------------------

Then you press tab, to switch from the place $1 to the place $2.

If you are not in a snippet, the tab key works normal.

I figured out the function that's get called when you press Tab into snippet, is yas-next-field. I would like to bind the function to another key instead Tab.

But only when it's inside a snippet, not affecting the normal working of another key outside snippet, like Tab already is.

But I couldn't find any refefence on internet about keymapping for only inside yasnippet, not as normal key.

Thanks in advance for the suggestion, it's really appreciated.


Customize yas-keymap for that.

(eval-after-load 'yasnippet
     (define-key yas-keymap (kbd "TAB") nil)
     (define-key yas-keymap (kbd "C-o") 'yas-next-field-or-maybe-expand)))
| improve this answer | |
  • Thanks Wasamasa! That worked it right. But how could you figure that out, if I might ask? I found nothing about that on Yasnippet documentation. – ReneFroger Apr 20 '15 at 6:55
  • I've read the source code and found three keymaps, one of which was using yas-next-field-or-maybe-expand. – wasamasa Apr 20 '15 at 8:14
  • Reading the source code, that could be an option too... would be a hell of job for me personally. I still have some difficulties to understand Elisp code. I'm planning to learn Elisp at the end of April. Thanks Wasama, it's really appreciated. – ReneFroger Apr 20 '15 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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