vim 如何设置 python 标准库的高亮和补全

如题所述

第1个回答  2016-11-21

  可以代码添加到vim语法高亮

  将下面代码添加符合到的后面就可以了:

  syn keyword pythonStatement False, None, True

  syn keyword pythonStatement as assert break continue del exec global syn
keyword pythonStatement lambda nonlocal pass print return with yield syn keyword
pythonStatement class def nextgroup=pythonFunction skipwhite

  syn keyword pythonConditional elif else if

  syn keyword pythonRepeat for while

  syn keyword pythonOperator and in is not or

  syn keyword pythonException except finally raise try

  syn keyword pythonInclude from import

          



 

  可以代码添加到vim中vim语法补全

  1、修改_vimrc

  2、在_vimrc文件中加入如下这几行:

  let g:pydiction_location='C:/program
files/vim/vimfiles/ftplugin/pydiction/complete-dict'

  filetype plugin on

  set autoindent

  syntax enable

  set softtabstop=4

  set shiftwidth=4

  set number


  使用:

  如果是开新的python档案,尚未储存为 .py,VIM不知道目前编辑的是python,所以要在vim的命令列里面下这个指令 set
FileType=python ,之后,按tab就会列出method和attribute了