ubuntu16.04制作vim和python3的开发环境


Posted in Python onSeptember 23, 2018

1. 安装vim:

# apt-get install  -y vim-gnome

2. 安装ctags,ctags用于支持taglist

# apt-get install ctags

3. 安装taglist

# apt-get install vim-scripts vim-addon-manager
# vim-addons install taglist

4. 安装pydiction 实现代码补全:

#wget  https://www.vim.org/scripts/script.php?script_id=850/pydiction-1.2.3.zip
# unzip pydiction-1.2.3.zip
# cd pydiction/after/ftplugin/
# mkdir /usr/share/vim/vim74/pydiction
# cp  -rp python_pydiction.vim  /usr/share/vim/vim74/ftplugin/
# cp complete-dict pydiction.py  /usr/share/vim/vim74/pydiction/

5.安装python_fold自动折叠插件

    下载python_fold.vim:
 https://www.vim.org/scripts/script.php?script_id=515
 
 # mv python_fold.vim /usr/share/vim/vim74/plugin/
 
  #vim /root/.vimrc
 set foldmethod=indent

6. 生成ctag序列:

 进入到python脚本所在的目录,在该目录下执行:
  # ctags -R *
  生成一个 ctags 文件,该文件记录了程序/项目的函数、类等的分析序列记录.

7. 安装taglist插件:

 下载插件:
  https://www.vim.org/scripts/script.php?script_id=273
 # unzip taglist_46.zip
 # cp plugin/taglist.vim  /usr/share/vim/vim74/plugin/
 # cp doc/taglist.txt  /usr/share/vim/vim74/doc/
 #vim
 :helptags /usr/share/vim/vim74/doc        "生成taglist帮助文件列表。
 : help taglist.txt        “查看taglist帮助信息。

8. 安装vim  plug:

 # mkdir ~/.vim/autoload/
 # cd ~/.vim/autoload/
 # wget https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

 配置vim plug:

#vim /root/.vimrc
 call plug#begin('~/.vim/autoload')          
 Plug 'Valloric/YouCompleteMe'             
 call plug#end() 

#vim /root/.vimrc
filetype off         " required
 
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle
call vundle#begin()
 
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-scripts/indentpython.vim'
Bundle 'Valloric/YouCompleteMe'

" All of your Plugins must be added before the following line
call vundle#end()      " required
filetype plugin indent on  " required

call plug#begin('~/.vim/autoload')
Plug 'Valloric/YouCompleteMe'

call plug#end()

set nocompatible "关闭与vi的兼容模式
set number "显示行号
set nowrap  "不自动折行
set showmatch  "显示匹配的括号
set scrolloff=3    "距离顶部和底部3行"
set encoding=utf-8 "编码
set fenc=utf-8   "编码
"set mouse=a    "启用鼠标
set hlsearch    "搜索高亮
syntax on  "语法高亮
set helplang=cn
set encoding=utf-8

"au BufNewFile,BufRead *.py
set tabstop=4
set softtabstop=4
set shiftwidth=4
set textwidth=79
set expandtab
set autoindent
set fileformat=unix
set foldmethod=indent
set autoindent " 实现自动缩进
set foldmethod=indent
set shiftwidth=4
set expandtab
set number

"Flagging Unnecessary Whitespace
highlight BadWhitespace ctermbg=red guibg=darkred

let Tlist_Auto_Highlight_Tag=1
let Tlist_Auto_Open=1
let Tlist_Auto_Update=1
let Tlist_Display_Tag_Scope=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Enable_Dold_Column=1
let Tlist_File_Fold_Auto_Close=1
let Tlist_Show_One_File=1
let Tlist_Use_Right_Window=1
let Tlist_Use_SingleClick=1
filetype plugin on

let g:pydiction_location = '/usr/share/vim/vim74/pydiction/complete-dict' 
let g:pydiction_menu_height = 20
autocmd FileType python set omnifunc=pythoncomplete#Complete


let Tlist_Show_One_File = 1  "不同时显示多个文件的tag,只显示当前文件的    
let Tlist_Exit_OnlyWindow = 1 "如果 taglist 窗口是最后一个窗口,则退出 vim     
let Tlist_Use_Right_Window = 1 "在右侧窗口中显示 taglist 窗口   
"let Tlist_Auto_Open=1  "在启动 vim 后,自动打开 taglist 窗口
"let Tlist_File_Fold_Auto_Close=1 "只显示当前文件 tag,其它文件的tag折叠 

let Tlist_Auto_Highlight_Tag=1
let Tlist_Auto_Open=1
let Tlist_Auto_Update=1
let Tlist_Display_Tag_Scope=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Enable_Dold_Column=1
let Tlist_File_Fold_Auto_Close=1
let Tlist_Show_One_File=1
let Tlist_Use_Right_Window=1
let Tlist_Use_SingleClick=1
nnoremap <silent> <F8> :TlistToggle<CR>
filetype plugin on
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascrīpt set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete

插件安装:

    切换到命令行模式,依次输入
    PlugStatus
    PlugInstall
    就可以安装插件了
    使用vim plug可以方便的管理插件
    查看插件类型:
    :PlugStatus
    安装插件:
    :PlugInstall
    更新插件::PlugUpdate
    vim-plug本身更新::PlugUpgrade

Python 相关文章推荐
Python中函数的参数传递与可变长参数介绍
Jun 30 Python
利用python画一颗心的方法示例
Jan 31 Python
详谈python http长连接客户端
Jun 12 Python
Python使用win32com实现的模拟浏览器功能示例
Jul 13 Python
anaconda如何查看并管理python环境
Jul 05 Python
Python正则表达式匹配日期与时间的方法
Jul 07 Python
python+Django+pycharm+mysql 搭建首个web项目详解
Nov 29 Python
Django实现任意文件上传(最简单的方法)
Jun 03 Python
为什么说python适合写爬虫
Jun 11 Python
教你怎么用Python处理excel实现自动化办公
Apr 30 Python
如何理解python接口自动化之logging日志模块
Jun 15 Python
python字符串的一些常见实用操作
Apr 06 Python
Python实现注册、登录小程序功能
Sep 21 #Python
用于业余项目的8个优秀Python库
Sep 21 #Python
Python 经典面试题 21 道【不可错过】
Sep 21 #Python
python使用folium库绘制地图点击框
Sep 21 #Python
在python中安装basemap的教程
Sep 20 #Python
python编程使用协程并发的优缺点
Sep 20 #Python
详解Numpy中的广播原则/机制
Sep 20 #Python
You might like
overlord人气高涨,却被菲利普频繁举报,第四季很难在国内上映
2020/05/06 日漫
PHP二维数组的去重问题解析
2011/07/17 PHP
PHP中集成PayPal标准支付的实现方法分享
2012/02/06 PHP
php mysql_real_escape_string函数用法与实例教程
2013/09/30 PHP
PHP实现利用MySQL保存session的方法
2014/08/23 PHP
php提高网站效率的技巧
2015/09/29 PHP
php检查页面是否被百度收录
2015/10/28 PHP
PHP7 echo和print语句实例用法
2019/02/15 PHP
js中使用DOM复制(克隆)指定节点名数据到新的XML文件中的代码
2011/07/27 Javascript
终于解决了IE8不支持数组的indexOf方法
2013/04/03 Javascript
javascript判断网页是关闭还是刷新
2015/09/12 Javascript
angular分页指令操作
2017/01/09 Javascript
JS实现简易刻度时钟示例代码
2017/03/11 Javascript
javascript 函数的暂停和恢复实例详解
2020/04/25 Javascript
用Python实现服务器中只重载被修改的进程的方法
2015/04/30 Python
Python中的模块导入和读取键盘输入的方法
2015/10/16 Python
Python批量查询域名是否被注册过
2017/06/21 Python
Python基于正则表达式实现文件内容替换的方法
2017/08/30 Python
python3 pillow生成简单验证码图片的示例
2017/09/19 Python
利用python打开摄像头及颜色检测方法
2018/08/03 Python
python3.4爬虫demo
2019/01/22 Python
Python发展简史 Python来历
2019/05/14 Python
解决pycharm 远程调试 上传 helpers 卡住的问题
2019/06/27 Python
python二元表达式用法
2019/12/04 Python
python根据用户需求输入想爬取的内容及页数爬取图片方法详解
2020/08/03 Python
python安装cx_Oracle和wxPython的方法
2020/09/14 Python
python实现逻辑回归的示例
2020/10/09 Python
移动端html5模拟长按事件的实现方法
2018/09/30 HTML / CSS
Android笔试题总结
2014/11/29 面试题
中学实习教师自我鉴定
2013/12/12 职场文书
捐资助学倡议书
2014/04/15 职场文书
改革共识倡议书
2014/08/29 职场文书
学习退步检讨书
2014/09/28 职场文书
校长新学期致辞
2015/07/30 职场文书
丧事答谢词大全
2015/09/30 职场文书
2019年七夕情人节浪漫祝福语大全!
2019/08/08 职场文书