经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 程序设计 » Python3 » 查看文章
ubuntu16.04制作vim和python3的开发环境
来源:jb51  时间:2018/9/26 17:38:25  对本文有异议

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:

  1.  #vim /root/.vimrc
  2.  call plug#begin('~/.vim/autoload')          
  3.  Plug 'Valloric/YouCompleteMe'             
  4.  call plug#end() 
  5.  
  6. #vim /root/.vimrc
  7. filetype off         " required
  8.  
  9. " set the runtime path to include Vundle and initialize
  10. set rtp+=~/.vim/bundle/vundle
  11. call vundle#begin()
  12.  
  13. " let Vundle manage Vundle, required
  14. Plugin 'VundleVim/Vundle.vim'
  15. Plugin 'vim-scripts/indentpython.vim'
  16. Bundle 'Valloric/YouCompleteMe'
  17.  
  18. " All of your Plugins must be added before the following line
  19. call vundle#end()      " required
  20. filetype plugin indent on  " required
  21.  
  22. call plug#begin('~/.vim/autoload')
  23. Plug 'Valloric/YouCompleteMe'
  24.  
  25. call plug#end()
  26.  
  27. set nocompatible "关闭与vi的兼容模式
  28. set number "显示行号
  29. set nowrap  "不自动折行
  30. set showmatch  "显示匹配的括号
  31. set scrolloff=3    "距离顶部和底部3"
  32. set encoding=utf-8 "编码
  33. set fenc=utf-8   "编码
  34. "set mouse=a    "启用鼠标
  35. set hlsearch    "搜索高亮
  36. syntax on  "语法高亮
  37. set helplang=cn
  38. set encoding=utf-8
  39.  
  40. "au BufNewFile,BufRead *.py
  41. set tabstop=4
  42. set softtabstop=4
  43. set shiftwidth=4
  44. set textwidth=79
  45. set expandtab
  46. set autoindent
  47. set fileformat=unix
  48. set foldmethod=indent
  49. set autoindent " 实现自动缩进
  50. set foldmethod=indent
  51. set shiftwidth=4
  52. set expandtab
  53. set number
  54.  
  55. "Flagging Unnecessary Whitespace
  56. highlight BadWhitespace ctermbg=red guibg=darkred
  57.  
  58. let Tlist_Auto_Highlight_Tag=1
  59. let Tlist_Auto_Open=1
  60. let Tlist_Auto_Update=1
  61. let Tlist_Display_Tag_Scope=1
  62. let Tlist_Exit_OnlyWindow=1
  63. let Tlist_Enable_Dold_Column=1
  64. let Tlist_File_Fold_Auto_Close=1
  65. let Tlist_Show_One_File=1
  66. let Tlist_Use_Right_Window=1
  67. let Tlist_Use_SingleClick=1
  68. filetype plugin on
  69.  
  70. let g:pydiction_location = '/usr/share/vim/vim74/pydiction/complete-dict' 
  71. let g:pydiction_menu_height = 20
  72. autocmd FileType python set omnifunc=pythoncomplete#Complete
  73.  
  74.  
  75. let Tlist_Show_One_File = 1  "不同时显示多个文件的tag,只显示当前文件的    
  76. let Tlist_Exit_OnlyWindow = 1 "如果 taglist 窗口是最后一个窗口,则退出 vim     
  77. let Tlist_Use_Right_Window = 1 "在右侧窗口中显示 taglist 窗口   
  78. "let Tlist_Auto_Open=1  "在启动 vim 后,自动打开 taglist 窗口
  79. "let Tlist_File_Fold_Auto_Close=1 "只显示当前文件 tag,其它文件的tag折叠 
  80.  
  81. let Tlist_Auto_Highlight_Tag=1
  82. let Tlist_Auto_Open=1
  83. let Tlist_Auto_Update=1
  84. let Tlist_Display_Tag_Scope=1
  85. let Tlist_Exit_OnlyWindow=1
  86. let Tlist_Enable_Dold_Column=1
  87. let Tlist_File_Fold_Auto_Close=1
  88. let Tlist_Show_One_File=1
  89. let Tlist_Use_Right_Window=1
  90. let Tlist_Use_SingleClick=1
  91. nnoremap <silent> <F8> :TlistToggle<CR>
  92. filetype plugin on
  93. autocmd FileType python set omnifunc=pythoncomplete#Complete
  94. autocmd FileType javascrīpt set omnifunc=javascriptcomplete#CompleteJS
  95. autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
  96. autocmd FileType css set omnifunc=csscomplete#CompleteCSS
  97. autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
  98. autocmd FileType php set omnifunc=phpcomplete#CompletePHP
  99. autocmd FileType c set omnifunc=ccomplete#Complete
  100. autocmd FileType python set omnifunc=pythoncomplete#Complete

插件安装:

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

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号