700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > python自动补全vim_Python 自动补全(vim)

python自动补全vim_Python 自动补全(vim)

时间:2020-06-28 16:59:43

相关推荐

python自动补全vim_Python 自动补全(vim)

一、vim python自动补全插件:pydiction

可以实现下面python代码的自动补全:

1.简单python关键词补全

2.python 函数补全带括号

3.python 模块补全

4.python 模块内函数,变量补全

5.from module import sub-module 补全

想为vim启动自动补全需要下载插件,地址如下:

/scripts/script.php?script_id=850

/rkulla/pydiction

安装配置:

wget /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键进行补全。如下图:

Python函数中定义参数的四种方式

Python中函数参数的定义主要有四种方式:1.F(arg1,arg2,…)这是最常见的定义方式,一个函数可以定义任意个参数,每个参数间用逗号分割,用这种方式定

Python中3种内建数据结构:列表、元组和字典

Python中有3种内建的数据结构:列表、元组和字典。参考简明Python教程1.列表list是处理一组有序项目的数据结构,即你可以在一个列表中存储一个序列的

python字符串替换的2种方法

python字符串替换是python操作字符串的时候经常会碰到的问题,这里简单介绍下字符串替换方法。python字符串替换可以用2种方法实现:1是用字符串本身的

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。