搭建树莓派python开发环境

安装完镜像环境后,就可以在树莓派上开发了,为了开发opencv for python,我在树莓派上搭建了vim的python开发环境,除了配置.vimrc以外还要安利一款VIM python 自动补全插件:pydiction。这是在纯shell环境下进行python编程的一款利器。
pydiction可以实现下面python代码的自动补全:
简单python关键词补全
python 函数补全带括号
python 模块补全
python 模块内函数,变量补全
from module import sub-module 补全

1、安装vim

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

2、在github中clone插件

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

这里作者推荐使用vimogen(https://github.com/rkulla/vimogen)这款vim插件管理工具来安装pydiction.

3、配置vimrc

vim ~/.vimrc

在配置文件最下面填写

" 载入文件类型插件
filetype plugin on
" 配置插件路径
let g:pydiction_location = '~/.vim/bundle/pydiction/complete-dict'
" 设置补全菜单的高度
let g:pydiction_menu_height = 3

至此插件安装完毕,VIM中直接用 键就可以实现自动补全。
搭建树莓派python开发环境_第1张图片
成功看到补全菜单弹出证明插件已经成功安装。

最后,贴出我的vimrc配置方案。

" 配色方案(可用 :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 = '/home/pi/.vim/bundle/pydiction/complete-dict'

" 设置pydiction补全菜单的高度
let g:pydiction_menu_height = 3

你可能感兴趣的:(树莓派)