I have configured yasnippet and auto-complete bindings so it won't collide, auto complete uses <tab>
and yasnippet uses <backtab>
:
(add-to-list 'load-path
"~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)
;; Remove Yasnippet's default tab key binding
(define-key yas-minor-mode-map (kbd "<tab>") nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)
;; Set Yasnippet's key binding to shift+tab
(define-key yas-minor-mode-map (kbd "<backtab>") 'yas-expand)
I created two yasnippets one with the key lorem_dummy
and the other with the key lorem_image
, one of the examples:
# -*- mode: snippet; require-final-newline: nil -*-
# name: lorem_image
# key: lorem_image
# binding: direct-keybinding
# --
<img src="http://lorempixel.com/${1:width}/${2:height}/${3:$$(yas-choose-value '("abstract" "city" "animals" "food" "people" "transport" "business" "sports" "technics"))}/${4:text}" alt="$3">
is it possible to make Emacs auto complete work if I just write lorem and press to show in a dropdown the two choices ( lorem_dummy
and lorem_image
)? Because right now it doesn't come up the yasnippets, but the regular autocomplete does work ( variables and the rest of the stuff ).
-- update --
Ok, this is strange, after following the solution in the "duplicated question" link, everything seemed to work perfectly, but then after a few hours it started to behave strange, randomdly, sometimes it works sometimes it doesn't. I made a video showing the problem, it works, then I restart Emacs and stops working again.