I want to emulate (and even replace) some electric modes (eg. cperl-electric
, ruby-electric
) with my own custom templates using yasnippet
, but it doesn't seem to be possible - can someone enlighten me?
So in addition to normal templates triggered by TAB, I'd like to have some snippets triggered simply by a space, eg. typing "forSPACE" should fire a snippet instead of having to type "forTAB".
Is that possible?
Update: I also realise that for some "electric" features I want some patterns to fire without any sort of trigger key - eg. like cperl-mode turns { into a paired {} with the insertion point in the middle, I'd like to do the same for single and double quotes. (Of course in this case what I really want is paren-mode
to work with syntax less regular than lisp, but I fought that battle some years ago with only limited success!)
abbrev-mode
.abbrev-mode
before. It's a bit confusing! I also realised that to properly do "electric" things I need some patterns to fire without a space, eg. turning a ' into a paired '' with the insertion point in the middle.