Nothing happends when pressing tab

54 views
Skip to first unread message

Martin Lundberg

unread,
Apr 4, 2011, 4:18:45 PM4/4/11
to xptem...@googlegroups.com
Hi,

I just installed xptemplate and I've added this to my .vimrc

let g:xptemplate_key = '<Tab>'

And when I do :verbose imap <Tab> I get

i  <Tab>       * <C-R>=XPTemplateStart(0,{'k':'<Tab++'})<CR>
        Last set from ~/Dropbox/configs/.vim/bundle/xptemplate-dist/plugin/xptemplate.conf.vim

Not sure how to see what is wrong. Any ideas?

-Martin

Kent Sibilev

unread,
Apr 4, 2011, 4:28:21 PM4/4/11
to xptem...@googlegroups.com
Looks fine to me. Try enter d and <Tab>. It should enter the current date.

> --
> 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.
>

--
Kent

Martin Lundberg

unread,
Apr 4, 2011, 4:31:00 PM4/4/11
to xptem...@googlegroups.com
If I do d<Tab> I'm shown a popup with three choices:

default default ...:
do do { .. } while ( .. )
Date

And if I go down to DAte and press enter I get the current date. I
wonder why fun isn't working.

Martin Lundberg

unread,
Apr 4, 2011, 4:34:43 PM4/4/11
to xptem...@googlegroups.com
I found the error. I've got AutoComplPop plugin installed which shows
the completion window automatically when I write fun and I guess the
tab click is not getting to xptemplates then. If I disable the
autopopup it works. I wonder how I would make this work together.

On Mon, Apr 4, 2011 at 10:28 PM, Kent Sibilev <ksr...@gmail.com> wrote:

dr-dr xp

unread,
Apr 5, 2011, 1:00:22 AM4/5/11
to xptem...@googlegroups.com
There is no way for XPT to figure out what user actually want it to do if <tab> is used as trigger key: navigate through popup menu, or discard popup menu and trigger snippet.

If you are sure about that all of key press of <tab> are meant to trigger snippet. a quick solution might be using a delegation:
imap <M-i> <C-V><C-V><BS><Tab>

<M-i> closes popupmenu, and then does what <tab> should do.
 
  
要了几天饱饭就不记得西北风啥味了

Martin Lundberg

unread,
Apr 5, 2011, 3:02:00 AM4/5/11
to xptem...@googlegroups.com
Could you explain that some more? Does tab navigate through a popup?
:h popupmenu-keys says "Stop completion without changing the match and
insert the typed character.". I've got some special handling already
for my popup menu with this code

inoremap <expr> <c-n> pumvisible() ? "\<c-n>" :
"\<c-n>\<c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<cr>"

I don't quite understand it because I've taken it from the vim wiki
but it seems as if I can change the meaning of a character depending
on if the popup menu is visible or not. Could I not do the same with
tab? I always want tab to discard the popup menu and execute the
snippet. I never use tab to choose something from a popup I always use
ctrl-n and enter :)

-Martin

2011/4/5 dr-dr xp <drd...@gmail.com>:

dr-dr xp

unread,
Apr 5, 2011, 3:41:54 AM4/5/11
to xptem...@googlegroups.com
The explanation from :h is the default behavior defined by VIM. <tab> as navigate key is what SuperTab does.
SuperTab is widely used, thus I made XPT do in the same way.

If you just only want <tab> to trigger snippet:

let g:xptemplate_key = '<Plug>triggerxpt'                                          
inoremap <Plug>closePUM <C-v><C-v><BS>                                             
imap <tab> <Plug>closePUM<Plug>triggerxpt

This should work, but I am not sure if it works perfect. :|
 

2011/4/5 Martin Lundberg <martin....@gmail.com>



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

Martin Lundberg

unread,
Apr 5, 2011, 7:21:29 AM4/5/11
to xptem...@googlegroups.com
Well, I want the tab key to be able to insert tabs too. But when the
popupmenu is shown then I always want it to trigger a template (if
there is one)

Sorry if I'm complicating things but I would really want to use both
of these plugins. It worked with snipMate but I wanted to use
xptemplate because it's being actively developed and supports more
features :)

2011/4/5 dr-dr xp <drd...@gmail.com>:

dr-dr xp

unread,
Apr 5, 2011, 8:16:54 AM4/5/11
to xptem...@googlegroups.com
Sorry I forgot the fallback setting: 
let g:xptemplate_fallback = 'nore:<TAB>'

With this if no snippet matched XPT outputs a normal <TAB> keystroke.

Is it all you want now? :)



--
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.




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

Martin Lundberg

unread,
Apr 5, 2011, 8:36:20 AM4/5/11
to xptem...@googlegroups.com
Almost... :) I believe the AutoComplPop needs to be changed because
now when I for example do fun<Tab> I get the template:

function funName( ) {
/* cursor */
}

however when I write a name lets say 'var' the autocomple popup is
shown in this case showing 'var_dump'. When I then hit <Tab> again a
tab character is inserted making the code look like this:

function funName ( ) {
/* cursor */
}

Now if I hit <tab> again xptemplate moves me into the parameter
placeholder but the same things happends there.

I thought maybe we could disable auto popup plugin when activating a
template? The plugin as the command AutoComplPopDisable and
AutoComplPopEnable. Could this be used? :)

-Martin

2011/4/5 dr-dr xp <drd...@gmail.com>:

dr-dr xp

unread,
Apr 11, 2011, 7:47:56 AM4/11/11
to xptem...@googlegroups.com
In an earlier version of XPT it disable ACP when filling in a snippet. 
After some users complains about that they can't use ACP and XPT together, I removed this feature.
It seems I'd better re-enable it as a optional feature.

2011/4/5 Martin Lundberg <martin....@gmail.com>



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

Martin Lundberg

unread,
Apr 11, 2011, 7:54:18 AM4/11/11
to xptem...@googlegroups.com
It's hard to make everyone happy. In this case that would greatly
enhance my experience though :)

2011/4/11 dr-dr xp <drd...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages