搭建樹莓派python開發環境
阿新 • • 發佈:2019-02-17
安裝完映象環境後,就可以在樹莓派上開發了,為了開發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
3、配置vimrc
vim ~/.vimrc
在配置檔案最下面填寫
" 載入檔案型別外掛
filetype plugin on
" 配置外掛路徑
let g:pydiction_location = '~/.vim/bundle/pydiction/complete-dict'
" 設定補全選單的高度
let g:pydiction_menu_height = 3
至此外掛安裝完畢,VIM中直接用 鍵就可以實現自動補全。
成功看到補全選單彈出證明外掛已經成功安裝。
最後,貼出我的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