您的位置:首页 > 编程语言 > Python开发

配置vim for python

2016-07-24 01:57 471 查看
标签(空格分隔): vim python 自动补全

1.pathogen 插件管理器

描述

Manage your ‘runtimepath’ with ease. In practical terms, pathogen.vim makes it super easy to install plugins and runtime files in their own private directories.

下载地址:http://www.vim.org/scripts/script.php?script_id=2332

安装

mkdir -p ~/.vim/autoload ~/.vim/bundle

curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

配置

Add this to your vimrc:

execute pathogen#infect()

If you’re brand new to Vim and lacking a vimrc, vim ~/.vimrc and paste in the following super-minimal example:

execute pathogen#infect()

syntax on

filetype plugin indent on

Now any plugins you wish to install can be extracted to a subdirectory under ~/.vim/bundle, and they will be added to the ‘runtimepath’.

2.Pydiction tab键自动补全

描述

Pydiction allows you to Tab-complete Python code in Vim such as keywords, built-ins, standard library, and third-party modules.

下载地址:http://vim.sourceforge.net/scripts/script.php?script_id=850

安装

cd ~/.vim/bundle

git clone https://github.com/rkulla/pydiction.git

配置

In your vimrc file, first add the following line to enable filetype plugins:

filetype plugin on

then make sure you set g:pydiction_location to the full path of where you installed complete-dict. Ex:

let g:pydiction_location = ‘/path/to/complete-dict’

for example, if you used Pathogen to install Pydiction, you would set this to:

let g:pydiction_location = ‘/home/user/.vim/bundle/pydiction/complete-dict’

and the dictionary will be available to all of your virtualenv’s as well.

You can change the height of the completion menu by setting g:pydiction_menu_height in your vimrc:

let g:pydiction_menu_height = 3

3.syntastic 语法检查

描述

Syntastic is a syntax checking plugin for Vim that runs files through external syntax checkers and displays any resulting errors to the user.

下载地址:https://github.com/scrooloose/syntastic



Last but not least: syntastic doesn’t know how to do any syntax checks by itself. In order to get meaningful results you need to install external checkers corresponding to the types of files you use.

安装

Install syntastic as a Pathogen bundle

You now have pathogen installed and can put syntastic into ~/.vim/bundle like this:

cd ~/.vim/bundle && \

git clone –depth=1 https://github.com/scrooloose/syntastic.git

Quit vim and start it back up to reload it, then type:

:Helptags

Recommended settings

set statusline+=%#warningmsg#

set statusline+=%{SyntasticStatuslineFlag()}

set statusline+=%*

let g:syntastic_always_populate_loc_list = 1

let g:syntastic_auto_loc_list = 1

let g:syntastic_check_on_open = 1

let g:syntastic_check_on_wq = 0

pylint Python 代码分析工具

描述

Pylint 是一个 Python 代码分析工具,它分析 Python 代码中的错误,查找不符合代码风格标准

下载地址:https://www.pylint.org/

安装

ubuntu:sudo apt-get install pylint

要求

pylint需要使用到其他的软件包

1.astroid

安装:

git clone https://github.com/PyCQA/astroid/

sudo python setup.py install

2.isort

安装

ubuntu:git clone https://github.com/timothycrosley/isort.git

sudo python setup.py install

在.vimrc文件添加

let g:syntastic_python_checkers=[‘pylint’]

禁用syntastic对python的检查,但是不影响检查其他语言:

let g:syntastic_python_checkers=[]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: