您的位置:首页 > 编程语言 > Python开发

树莓派 Python Vim使用pydiction进行代码补全

2017-11-16 11:42 387 查看
这两天纠结着在树莓派中用哪个Python IDE好,想下载PyCharm但是怕跑起来卡,nano又特难用,最后还是回归Vim吧,毕竟网上这款神器的资料很全。

在树莓派中安装vim和git:

sudo apt-get update
sudo apt-get install vim git


克隆pydiction项目到本地:

mkdir -p ~/.vim/bundle
cd ~/.vim/bundle
git clone https://github.com/rkulla/pydiction.git cp -r ~/.vim/bundle/pydiction/after/ ~/.vim


配置.vimrc文件:

" 启用文件类型插件
filetype plugin on

" 配置pydiction插件路径
let g:pydiction_location = '~/.vim/bundle/pydiction/complete-dict'

" 设置pydiction补全菜单的高度,默认是8
let g:pydiction_menu_height = 20


最后,输入imp再按下Tab键就能代码补全和代码提示了



完整Vim命令:







以下是完整的.vimrc配置(改自:http://blog.csdn.net/talkxin/article/details/50499329):

" 配色方案(可用 :highlight 查看配色方案细节)
colorscheme murphy

" 打开语法高亮
syntax on

" 侦测文件类型
filetype on

" 载入文件类型插件
filetype plugin on

" 为不同文件类型使用不用缩进
filetype indent on

" =======
"
" 显示行号
set number

" 打开自动缩进
set autoindent

" 使用 C/C++ 的缩进方式
set cindent

" 为 C 程序提供自动缩进
set smartindent

" 设置自动缩进长度为四个空格
set shiftwidth=4

" 按退格键时可以一次删掉 4 个空格
set softtabstop=4

" 设定 tab 键长度为 4
set tabstop=4

" 将 tab 展开为空格
set expandtab

" 去掉输入错误时的提示声音
set noerrorbells

" 右下角显示光标位置
set ruler

" 总是显示状态行
set laststatus=2

" 自定义状态行
set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v]
"              | | | | |  |   |      |  |     |    |
"              | | | | |  |   |      |  |     |    +-- 当前列数
"              | | | | |  |   |      |  |     +-- 当前行数
"              | | | | |  |   |      |  +-- 当前光标位置百分比
"              | | | | |  |   |      +-- 使用的语法高亮器
"              | | | | |  |   +-- 文件格式
"              | | | | |  +-- 文件总行数
"              | | | | +-- 预览标志
"              | | | +-- 帮助文件标志
"              | | +-- 只读标志
"              | +-- 已修改标志
"              +-- 当前文件绝对路径

" 强调匹配的括号
set showmatch

" 光标短暂跳转到匹配括号的时间, 单位是十分之一秒
set matchtime=2

" 显示当前正在键入的命令
set showcmd

" 设置自动切换目录为当前文件所在目录,用 :sh 时候会很方便
set autochdir

" 搜索时忽略大小写
set ignorecase

" 随着键入即时搜索
set incsearch

" 有一个或以上大写字母时仍大小写敏感
set smartcase

" 代码折叠
"set foldenable

" 折叠方法
" manual 手工折叠
" indent 使用缩进表示折叠
" expr  使用表达式定义折叠
" syntax 使用语法定义折叠
" diff  对没有更改的文本进行折叠
" marker 使用标记进行折叠, 默认标记是 {{{ 和 }}}
"set foldmethod=indent

" 在左侧显示折叠的层次
"set foldcolumn=4

" =======
"
" 退出编辑模式时自动保存,条件为文件存在且可写,文件名非空(注:与Conque Shell冲突还未解决)
"if has("autocmd") && filewritable(bufname("%"))
"    autocmd InsertLeave ?* write
"endif

" 针对 Python 文件的设定
if has("autocmd")
autocmd FileType python set tabstop=4 shiftwidth=4 expandtab
endif

" 配置pydiction插件路径
let g:pydiction_location = '~/.vim/bundle/pydiction/complete-dict'

" 设置pydiction补全菜单的高度
let g:pydiction_menu_height = 20
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: