欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-09-28 15:41:43
1. 安装vim: # apt-get install  -y vim-gnome 2. 安装ctags,ctags用于支持taglist...

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 
# 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:
 
 
 # mv python_fold.vim /usr/share/vim/vim74/plugin/
 
  #vim /root/.vimrc
 set foldmethod=indent

6. 生成ctag序列:

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

7. 安装taglist插件:

 下载插件:
  
 # 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

 配置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