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

前端 未结 8 916
情歌与酒
情歌与酒 2021-02-01 04:07

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 na

相关标签:
8条回答
  • 2021-02-01 04:49

    The standard CTRL-N and CTRL-P work even better if you add the following to your ~/.vim/ftplugin/perl.vim file:

    set iskeyword+=:

    It will then auto-complete module names, etc.

    0 讨论(0)
  • 2021-02-01 04:50

    Ctrl+N

    This is explained in the Perl Hacks book, along with how to do Package completion. Highly recommended.

    0 讨论(0)
  • 2021-02-01 04:52

    https://github.com/c9s/perlomni.vim

    0 讨论(0)
  • 2021-02-01 04:58

    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.

    0 讨论(0)
  • 2021-02-01 04:58

    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.

    0 讨论(0)
  • 2021-02-01 05:04

    Ctrl-P (Get Previous Match) and Ctrl-N (Get Next Match) are kind of pseudo code completion. They basically search the file (Backwards for Ctrl-P, Forwards for Ctrl-N) you are editing (and any open buffers, and if you are using TAGS anything in your TAG file) for words that start with what you are typing and add a drop down list. It works surprisingly well for variables and function names, even if it isn't intellisense. Generally I use Ctrl-P as the variable or function I am looking for is usually behind in the code. Also if you keep the same copy of Vim open, it will search the files you have previously opened.

    0 讨论(0)
提交回复
热议问题