㈠ 如何在Vim中使用tab进行python代码补全
这里要介绍的功能叫"new-omni-completion(全能补全)", 你可以用下面的命令看看介绍: :help new-omni-completion 你还需要在~/.vimrc文件中增加下面两句: filetype plugin indent on 打开文件类型检测, 加了这句才可以用智能补全 set completeopt
㈡ python 怎么补全linux
Python自动补全有vim编辑下和python交互模式下,下面分别介绍如何在这2种情况下实现Tab键自动补全。
一、vim python自动补全插件:pydiction
可以实现下面python代码的自动补全:
简单python关键词补全
python 函数补全带括号
python 模块补全
python 模块内函数,变量补全
from mole import sub-mole 补全
想为vim启动自动补全需要下载插件,地址如下:
http://vim.sourceforge.net/scripts/script.php?script_id=850
https://github.com/rkulla/pydiction
安装配置:
wget https://github.com/rkulla/pydiction/archive/master.zip
unzip -q master
mv pydiction-master pydiction
mkdir -p ~/.vim/tools/pydiction
cp -r pydiction/after ~/.vim
cp pydiction/complete-dict ~/.vim/tools/pydiction
确保文件结构如下:
# tree ~/.vim
/root/.vim
├── after
│ └── ftplugin
│ └── python_pydiction.vim
└── tools
└── pydiction
└── complete-dict
创建~/.vimrc,确保其中内容如下:
# cat ~/.vimrc
filetype plugin on
let g:pydiction_location = '~/.vim/tools/pydiction/complete-dict'
用vim编辑一个py文件,import os.,这时候应该出现提示,证明成功
二、python交互模式下Tab自动补齐
创建文件如下:
# cat ~/.pythonstartup
# python startup file
#!/usr/bin/env python
import sys
import readline
import rlcompleter
import atexit
import os
# tab completion
readline.parse_and_bind('tab: complete')
# history file
histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)
del os, histfile, readline, rlcompleter
1
echo 'export PYTHONSTARTUP=~/.pythonstartup' >> ~/.bash_profile
重新登陆shell,输入python命令进入交互模式,就可以用Tab键进行补全。
㈢ 怎样用vim自动补全python
Pydiction 可以是我们使用Tab键自动补全Python代码在Vim,是一款非常不错的插件。
Pydiction不需要安装,所有没有任何依赖包问题,Pydiction主要包含三个文件。
1
2
3
python_pydiction.vim -- Vim plugin that autocompletes Python code.
complete-dict -- Dictionary file of Python keywords, moles, etc.
pydiction.py -- Python script to add more words to complete-dict.
下载Pydiction
1
2
3
4
5
mkdir ~/.vim
mkidr ~/.vim/bundle
cd ~/.vim/bundle
#这里我们也可以自己下载好上传到linux系统中
git clone https://github.com/rkulla/pydiction.git
配置Pydiction
1
2
3
4
#- UNIX/LINUX/OSX: Put python_pydiction.vim in ~/.vim/after/ftplugin/
#- WINDOWS: Put python_pydiction.vim in C:\vim\vimfiles\ftplugin\
# Assuming you installed Vim to C:\vim\
cp -r ~/.vim/bundle/pydiction/after/ ~/.vim
新建.vimrc文件
1
vim ~/.vimrc
在.vimrc文件添加如下配置:
1
2
3
filetype plugin on
let g:pydiction_location = '~/.vim/tools/pydiction/complete-dict'
let g:pydiction_menu_height = 3
到此已经可以使用Tab键自动补全python代码了。
㈣ python开发软件中,除自带的idle,哪一个支持第三方库的tab自动补全
居然没人提到我大编辑器之神vim?
㈤ linux 下python 怎么支持tab 和删除
1.Python是一门动态语言,任何实体都可以动态地添加或删除属性。
2.一个类定义了一个作用域。
3.类实例也引入了一个作用域,这与相应类定义的作用域不同。
4.在类实例中查找属性的时候,首先在实例自己的作用域中查找,如果没有找到,则再在类定义的作用域中查找。
5.在对类实例属性进行赋值的时候,实际上会在类实例定义的作用域中添加一个属性(如果还不存在的话),并不会影响到相应类中定义的同名属性。
㈥ linux下的python ide怎么设置tab补全
在Python模式交互下,tab自动补全会提高代码效率,通过以下步骤可以很方便的实现自动补全。
1.获取操作目录
[root@liu site-packages]# pythonPython 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "right", "credits" or "license" for more information.>>> import sys>>> sys.path
['', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib64/python2.6/site-packages/gtk-2.0', '/usr/lib/python2.6/site-packages']>>> 123456789
可以看出,我的工作目录是/usr/lib/python2.6/site-packages/。
2.进入工作目录,编写tab.py补全文件
[root@liu site-packages]# cd /usr/lib/python2.6/site-packages/[root@liu site-packages]# vim tab.py 123
tab.py内容如下,建议粘贴的时候保证格式正确性
1 #!/usr/bin/python
2 # python tab file
3 import sys 4 import readline 5 import rlcompleter 6 import atexit 7 import os 8 # tab completion
9 readline.parse_and_bind('tab: complete') 10 # history file
11 histfile = os.path.join(os.environ['HOME'], '.pythonhistory') 12 try: 13 readline.read_history_file(histfile) 14 except IOError: 15 pass
16 atexit.register(readline.write_history_file, histfile) 17
18 del os, histfile, readline,
3.添加环境变量,使其生效
[root@liu site-packages]# cd [root@liu ~]# vim .bashrc123
在末尾添加一行
export PYTHONSTARTUP=/usr/lib/python2.6/site-packages/tab.py1
4.重读.bashrc文件
source .bashrc1
或者
. .bashrc1
5.测试效果
[root@liu ~]# python
Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "right", "credits" or "license" for more information.
>>> import math>>> math.math.__class__( math.acos( math.fsum(math.__delattr__( math.acosh( math.hypot(math.__dict__ math.asin( math.isinf(math.__doc__ math.asinh( math.isnan(math.__file__ math.atan( math.ldexp(math.__format__( math.atan2( math.log(math.__getattribute__( math.atanh( math.log10(math.__hash__( math.ceil( math.log1p(math.__init__( math.sign( math.modf(math.__name__ math.cos( math.pimath.__new__( math.cosh( math.pow(math.__package__ math.degrees( math.radians(math.__rece__( math.e math.sin(math.__rece_ex__( math.exp( math.sinh(math.__repr__( math.fabs( math.sqrt(math.__setattr__( math.factorial( math.tan(math.__sizeof__( math.floor( math.tanh(math.__str__( math.fmod( math.trunc(math.__subclasshook__( math.frexp(
>>> math.
完成。我一开始一直报错,然后通过排查就是因为tab.py格式不正确。注意其格式。
㈦ python tab补全是什么意思
比如关键字,print,当你输入pr时,按tab键,系统自动将int给你补上,就不用完整输入print