Speed up Python coding
From Vim Tips Wiki
created August 30, 2004 · complexity intermediate · author tocer · version 6.0
I think they can reduce typing times and speed up Python coding by at least 100%. The SuperTab script is a very cool script that automatically completes the word under the cursor. The pyCallTips script is a very useful script. It pops up a window at the bottom of vim where it displays the calltips of the word under your cursor when you type the word. If both of the two scripts are used together, it will generate the perfect effect. Let me show you how to do it.
The first step is to download and install both of them. Then edit complType="\<C-p>" to complType="\<C-n>" in line 21 in the SuperTab script file. This step is to fix SuperTab script searching backward to forward. And the order of searching is the same as display in the pyCallTips script. Now you create a new Python file, and input:
and press <F4>, I call it the "refresh key". Then you continue and input:
When you type word, you'll find changing continually in the bottom window call "Python Calltips window". When you input "os.ch", it display like this in the calltips window:
os.chdir chdir(path) Change the current working directory to the specified path. os.chmod chmod(path, mode) Change the access permissions of a file.
Maybe the first word "os.chdir" is what you want, you can press Tab key, and you'll find the word under the cursor is completed automatically. If you want is "os.chmod", you press Tab key again, "os.chmod" will be completed. It is useful, isn't it?
It will work well mostly. But if you type like: (it's a example only)
import sys sys.argv[1:].c
It display in the calltips window:
sys.argv.count L.count(value) -> integer -- return number of occurrences of value
It is real what you want, but the Tab key can't work. Don't worry, the pyCalltips map five key to solve the problem. It is <Alt-1> ... <Alt-5>. You can press <Alt-1> to select the first word, and <Alt-2> to the second, and so on. If the key is not enough, you can map it yourself in the script file.
If you open an existing python file, you don't press <F4> key until you type new "import xxx" or "from xxx import xxx". you can also remap <F4> to other key.
In newer versions of the plugin, refresh key is not needed.
Fix bug "when using <BS> to delete the whole word", edit python calltips on line 169 to:
try: docs = CT_GetHelpDoc(CT_GetWordUnderCursor()) except AttributeError: return
Also to disable warnings (which triggeres vim.error) include this line somewhere at the begining:
import warnings warnings.simplefilter('ignore')
There is another bug in the script above with <BS> and empty lines. Use the following code instead
try: docs = CT_GetHelpDoc(CT_GetWordUnderCursor()) except AttributeError: docs =