如何使用vim编辑器打造pythonIDE,实现代码自动补全,自动缩进等

1、vim—自动缩进(编写Python脚本)

使用vim编写python文件的时候不能按照正常的编辑器进行缩进,需要修改vimrc文件。Ubuntu系统下vimrc文件的位置:

$ cd /etc/vim/

$ sudo vim vimrc

添加如下到vimrc文件的最下方:

set filetype=python
au BufNewFile,BufRead *.py,*.pyw setf python
set autoindent " same level indent
set smartindent " next level indent
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4

然后便实现了自动缩进功能。

2、实现智能提示及代码自动补全功能

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

1.简单python关键词补全
2.python 函数补全带括号
3.python 模块补全
4.python 模块内函数,变量补全
5.from module import sub-module 补全

首先我们需要安装一个插件:pydiction
下面的两个链接是安装包
http://vim.sourceforge.net/scripts/script.php?script_id=850

https://github.com/rkulla/pydiction

也可以直接在xshell中使用命令安装:

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文件 touch ~/.vimrc
连接文件 cat ~/.vimrc
添加如下代码到vimrc文件中 vim vimrc

filetype plugin on
let g:pydiction_location = '~/.vim/tools/pydiction/complete-dict'
let g:pydiction_menu_height = 3

现在打开vim编辑器就可以实现如上功能了
使用Tab键就可以联想代码了。
在这里插入图片描述
在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

2439644676

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值