Quantcast

Cannot map <Tab> to auto completion

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Cannot map <Tab> to auto completion

Ansman
No matter what I do I cannot bind <Tab> to autocompletion in insert mode.

I've tried removing my vimrc and just having set nocompatible and it still doesn't work.
Running :verbose set cp? wc? shows
nocompatible
        Last set from ~/.vimrc
  wildchar=<Tab>
        Last set from ~/.vimrc

What am I missing?

P.S. <ctrl>+<n> works just fine.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cannot map <Tab> to auto completion

Ben Schmidt
On 18/05/12 8:08 PM, Ansman wrote:

> No matter what I do I cannot bind<Tab>  to autocompletion in insert mode.
>
> I've tried removing my vimrc and just having set nocompatible and it still
> doesn't work.
> Running :verbose set cp? wc? shows
> nocompatible
>          Last set from ~/.vimrc
>    wildchar=<Tab>
>          Last set from ~/.vimrc
>
> What am I missing?
>
> P.S.<ctrl>+<n>  works just fine.

Strange nobody replied to this.

'wildchar' only applies to commandline mode, not insert mode.

I make <Tab> work the way I want it in insert mode, and enabled by
default only for PHP files, with this in my .vimrc:

function! TabCompletion()
    inoremap <buffer> <expr> <Tab>
       \ col('.')==1\|\|match(getline('.')[col('.')-2],'\s')!=-1?
       \ "\<Tab>":"\<C-N>"
endfunction
function! TabCompletionOff()
    iunmap <buffer> <Tab>
endfunction
command! TabCompletion call TabCompletion()
command! TabCompletionOff call TabCompletionOff()
augroup TabCompletion
    au FileType php TabCompletion
augroup END

You may find this helpful.

Smiles,

Ben.



--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Loading...