Alex Rivera | Logout

Is there any way to enable code completion for Perl in vim?

Asked 2008-09-10T13:57:07.983
25

Surprisingly as you get good at vim, you can code even faster than standard IDEs such as Eclipse. But one thing I really miss is code completion, especially for long variable names and functions.

Is there any way to enable code completion for Perl in vim?

Edit
Report

2 Answers

8

Well, Vim's generic completion mechanism is surprisingly good, just using Ctrl-N in insert mode. Also, line completion is very handy, using C-x C-l.

Also check out this vim script for perl.

answered 2008-09-10T14:00:04.670
4

The .vimrc clip in one of the other answers is slightly wrong. To turn your tab key into an auto-complete key, use this code:

inoremap <tab> <c-r>=InsertTabWrapper()<cr>

function! InsertTabWrapper()
    let col = col('.') - 1
    if !col || getline('.')[col - 1] !~ '\k'
        return "\<tab>"
    else
        return "\<c-p>"
    endif
endfunction

You can find this, and tons of other vim tricks in this thread at Perlmonks--which links to even more threads with lots more customizations.

answered 2008-09-16T14:13:34.213

Your Answer