如何使用vim编辑器打造pythonIDE,实现代码自动补全,自动缩进等
发布日期:2021-07-01 04:04:34 浏览次数:2 分类:技术文章

本文共 1147 字,大约阅读时间需要 3 分钟。

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

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

$ cd /etc/vim/$ sudo vim vimrc

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

set filetype=pythonau BufNewFile,BufRead *.py,*.pyw setf pythonset autoindent " same level indentset smartindent " next level indentset expandtabset tabstop=4set shiftwidth=4set softtabstop=4

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

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

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

1.简单python关键词补全

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

首先我们需要安装一个插件: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 onlet g:pydiction_location = '~/.vim/tools/pydiction/complete-dict'let g:pydiction_menu_height = 3

现在打开vim编辑器就可以实现如上功能了

使用Tab键就可以联想代码了。
在这里插入图片描述
在这里插入图片描述

转载地址:https://monologue.blog.csdn.net/article/details/104372180 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:解决虚拟机和宿主主机的互相粘贴以及设置共享文件夹
下一篇:Xshell无法输入中文

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年04月13日 17时35分38秒