On Fri, 16 Jun 2006 at 8:25am, David Fishburn wrote:

>
>
> > -----Original Message-----
> > From: Hari Krishna Dara [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, June 15, 2006 8:23 PM
> > To: vim@vim.org
> > Subject: Inability to map <C-N> when completion popup is visible
> >
> >
> > I am trying to map <C-N> and <C-P> to behave differently when
> > pumvisible() returns true, but Vim seems to completely ignore this.
> > E.g., if I create this unconditional map (a much simpler one
> > than what I
> > wanted):
> >
> > inoremap <C-N> <C-C>
> >
> > pressing ^N normally stops insertmode, but when popup is
> > visible, Vim never executes the map. This may be true for
> > <C-P> also, but the same is not true for, say <Up>.
> >
> > inoremap <Up> <C-C>
> >
> > Using the above map, pressing <Up> arrow always stops insert
> > mode, whether popup is visible or not. Is this a bug? I
> > tested by starting with -u NONE option to avoid any other
> > interferences.
>
> I had a lot of problems trying to get this to work as well.
>
> In the end I was unable to map it without making a function call.
>
> autoload/sqlcomplete.vim does the following:
>
> if has('win32')
>       imap <buffer> <c-right> <C-R>=sqlcomplete#DrillIntoTable()<CR>
>       imap <buffer> <c-left>  <C-R>=sqlcomplete#DrillOutOfColumns()<CR>
> endif
>
> function! sqlcomplete#DrillIntoTable()
>     " If the omni popup window is visible
>     if pumvisible()
>         call sqlcomplete#Map('column')
>         " C-Y, makes the currently highlighted entry active
>         " and trigger the omni popup to be redisplayed
>         call feedkeys("\<C-Y>\<C-X>\<C-O>")
>     else
>         if has('win32')
>             " If the popup is not visible, simple perform the normal
>             " <C-Right> behaviour
>             exec "normal! \<C-Right>"
>         endif
>     endif
>     return ""
> endfunction
>
> In this case, if the popup window is not visible I want to perform the
> standard <C-Right> so the user does not loose any functionality due to the
> mapping.
>
> For the lurkers, this is for Vim7 since pumvisible() and feedkeys() are Vim7
> functions.
>
> HTH,
> Dave

I give up. The procedure you came up with works for other keys but not
for <C-N> (and possibly <C-P> as well). The function doesn't even get
called when completion popup is visible. Even for other keys where the
function gets called, I made several attempts to do what I want and none
worked properly. What I want is to remap <Down> to <C-N> (which is no
problem) but to also move the cursor to the end of the line before doing
<C-N>. I had two mixed results. In the first result, I am able to move
the cursor to the end, but <C-N> will then be treated as a trigger for
fresh insert mode completion (and I am not using a 'completefunc' to set
matches, so my completions get overwritten by what Vim generates by
default). In the second result, <C-N> works, but the cursor is not moved
to the end of the line. I tried to use all kinds of tricks mixing
the use of feedkeys(), inputsave/restore() and others. Something is very
fishy about <C-N>, when it is anywhere in the map (LHS or RHS),
everything else gets ignored.

-- 
Thanks,
Hari

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to