Don't enter insert mode after applying a wrapper snippet

5 views
Skip to first unread message

Geralt

unread,
Apr 22, 2011, 12:50:04 PM4/22/11
to xptemplate
Hi,

is it possible to prevent xptemplate from entering insert mode after
applying a wrapper snippet?


Thanks,

Geralt.

dr-dr xp

unread,
Apr 22, 2011, 1:18:36 PM4/22/11
to xptem...@googlegroups.com
XPT a wrap=x
-`x^-`^feedkeys("\<ESC>")^

You can see the second( and the last ) anonymous place holder has a onfocus function binded.
<ESC> could be other key you want to use to quit from insert-mode.



--
You received this message because you are subscribed to the Google Groups "xptemplate" group.
To post to this group, send email to xptem...@googlegroups.com.
To unsubscribe from this group, send email to xptemplate+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xptemplate?hl=en.




--
要了几天饱饭就不记得西北风啥味了

Geralt

unread,
Apr 22, 2011, 2:42:46 PM4/22/11
to xptemplate
On Apr 22, 7:18 pm, dr-dr xp <drdr...@gmail.com> wrote:
> XPT a wrap=x
> -`x^-`^feedkeys("\<ESC>")^
>
> You can see the second( and the last ) anonymous place holder has a onfocus
> function binded.
> <ESC> could be other key you want to use to quit from insert-mode.
>
so, there is no way to set this globally. I would have to change every
wrapper snippet?

dr-dr xp

unread,
Apr 22, 2011, 3:13:41 PM4/22/11
to xptem...@googlegroups.com
No way setting it globally. 

Your request is something special to XPT. With normal working flow XPT always ends in insert-mode.

If you really need this feature, making a plugin for  XPT could be a way.

Reference plugin/xpt.plugin.highlight.vim 
Use callback for event "after,finishAll"

In your callback function, arg1.renderContext.snipObject is a reference to snippet object just finished.



--
You received this message because you are subscribed to the Google Groups "xptemplate" group.
To post to this group, send email to xptem...@googlegroups.com.
To unsubscribe from this group, send email to xptemplate+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xptemplate?hl=en.




--
要了几天饱饭就不记得西北风啥味了

Geralt

unread,
Apr 22, 2011, 4:17:06 PM4/22/11
to xptemplate
I think I've managed to get it working :-)

-------------------------------------------------------------------

fun! s:LInsert(x, ctx)
if a:ctx.snipObject.setting.iswrap
call feedkeys("\<C-c>")
endif
endfunction

let s:LeaveInsert = function( '<SNR>' . s:sid . "LInsert" )
call g:XPTaddPlugin("finishAll" , 'after' , s:LeaveInsert )

-------------------------------------------------------------------

For testing I've put it into xpt.plugin.highlight.vim, because I'm not
sure what I need on boiler plate setup code for an XPT plugin. Is
there a template file for XPT plugins?

dr-dr xp

unread,
Apr 23, 2011, 7:48:11 AM4/23/11
to xptem...@googlegroups.com
No template. 

The only thing a plugin needs to do first is to load xptemplate.vim:
runtime plugin/xptemplate.vim



--
You received this message because you are subscribed to the Google Groups "xptemplate" group.
To post to this group, send email to xptem...@googlegroups.com.
To unsubscribe from this group, send email to xptemplate+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xptemplate?hl=en.




--
要了几天饱饭就不记得西北风啥味了
Reply all
Reply to author
Forward
0 new messages