2

I read that CTRL+P is the auto completion short cut in VI, but the recommendation given by the auto completion doesn't make that much sense to me.

Say from the re package there is a method called findall. Eclipse could recommend that method when I do CTRL+Space:

enter image description here

But When I tried the auto completion in VI, it could not find the findall method. the only recommendation seems like a command that I have typed before which has nothing to do with the re module.

enter image description here

Can Anyone give me some hints what is the auto completion story behind the CTRL+P in VI and how could I tune it up so it would be as good as Eclipse's auto completion.

(Every time I doubt the power of VI, the truth is always that it is me who lack the power to discover the beauty of VI)

Thanks!

glts
  • 19,167
  • 11
  • 65
  • 85
B.Mr.W.
  • 16,522
  • 30
  • 96
  • 156
  • possible duplicate of [Auto code completion in VIM?](http://stackoverflow.com/questions/2083566/auto-code-completion-in-vim) – glts Sep 14 '13 at 14:09
  • This question has been asked so many times before ... start here: http://stackoverflow.com/q/1115876. – glts Sep 14 '13 at 14:10

2 Answers2

3

In vim <C-p> is not the only completion shortcut available. Omni completion defined for python should be called with <C-x><C-o>, then use <C-n>/<C-p> to select variants. There are more completion types, all start with <C-x>, see :h ins-completion.

It is still better to use some third-party plugin (like jedi-vim or klen/python-mode) to get python completion as they are smarter. Note that at least klen/python-mode will not redefine <C-p>. They redefine <C-x><C-o> by setting 'omnifunc' option.

ZyX
  • 49,123
  • 7
  • 101
  • 128
0

Without any additional modules, vim's autocompletion only searches the current file for occurences of the string you've started typing, regardless of whether it makes sense. If you use the tags file, via ctags or other, you're able to use strings across a variety of files, rather than just the current buffer.

TankorSmash
  • 11,146
  • 5
  • 55
  • 96
  • Check out this question http://stackoverflow.com/questions/934233/cscope-or-ctags-why-choose-one-over-the-other/934523#934523 – TankorSmash Sep 13 '13 at 19:30
  • @TankorSmash You are wrong: vim runtime files do hold some python completion function that does not require tags files: http://code.google.com/p/vim/source/browse/runtime/autoload/pythoncomplete.vim?r=a83960ec9e6db913af1530ebe19d0126d99a7b96. But `` is a wrong shortcut for accessing it. – ZyX Sep 14 '13 at 18:50