Enable python autocomplete in Vim without any installation

I am coding Python3 in Vim and would like to enable autocomplete.

I have to use different computers without internet access. Each computer runs Linux with Vim preinstalled.

I don't want to install anything, I just want the easiest way to enable python3 completion (even if it's not the best completion), just something that is easy to resolve from scratch on a new Linux machine.

Many thanks

+3


source to share


3 answers


If you compiled vim with +python3

, you can try omnifunc. Add to your ~/.vimrc

:

au FileType python setl ofu=python3complete#Complete

      



Then in insert mode just type Ctrl X+ Ctrl O.

See :help omnifunc

.

0


source


Unfortunately Vim doesn't do what you want by default, you are pretty much limited by the Ctrl-P style which is better than it sounds when you get used to it.

However, I also often find myself working on machines that are not allowed internet access or have other files, and when I find myself in this situation and I use an unfamiliar language, I sometimes use a Vim dictionary for the dictionary: http: // vim .wikia.com / wiki / VimTip91



To populate this dictionary I cat / trim / filter the man pages for the language to get a variety of keywords. I put them in a dictionary of specific file types:au FileType * execute 'setlocal dict+=~/.vim/words/'.&filetype.'.txt'

Obviously, this is not the biggest solution and it is a little heavy, but it does provide a degree of "What is a function called" type.

+1


source


by default, Ctrl-P in insert mode does autocomplete with all words already present in the file being edited

0


source







All Articles