- Notifications
You must be signed in to change notification settings - Fork0
AntonTimiskov/python-mode
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Python-mode is a vim plugin that allows you to use thepylint,rope,pydoc,pyflakes libraries in vim to providefeatures like python code looking for bugs, refactoring and some other useful things.
This plugin allow you create python code in vim very easily.There is no need to install thepylint,rope or any used python library on your system.
- Highlight syntax errors
- Highlight and auto fix unused imports
- Python objects and motion (]], ]m, vac, vim, dim, ...)
- Strong code completion
- Code refactoring
- Python documentation
- Run python code
- Go to definition
- Powerful customization
- Virtualenv support
- And more...
See screencast here:http://t.co/3b0bzeXA (sorry for quality, this is my first screencast)
- Add python objects and motions (beta):h pymode_motion
- VIM >= 7.0 with python support(also
--with-features=big
if you want use g:pymode_lint_signs)
Usingpathogen (recomended)
% cd ~/.vim% mkdir -p bundle && cd bundle% git clone git://github.com/klen/python-mode.git
Enablepathogen in your
~/.vimrc
:" Pathogen loadfiletype offcall pathogen#infect()call pathogen#helptags()filetype plugin indent onsyntax on
% git clone git://github.com/klen/python-mode.git% cd python-mode.vim% cp -R * ~/.vim
Then rebuildhelptags in vim:
:helptags ~/.vim/doc/
Note
filetype-plugin (:help filetype-plugin-on
) andfiletype-indent (:help filetype-indent-on
)must be enabled for use python-mode.
Note
Also you can see vim help.:help PythonModeOptions
To change this settings, edit your~/.vimrc
:
" Disable pylint checking every savelet g:pymode_lint_write = 0" Set key 'R' for run python codelet g:pymode_run_key = 'R'
Default values:
" Load show documentation pluginlet g:pymode_doc = 1" Key for show python documentationlet g:pymode_doc_key = 'K'" Executable command for documentation searchlet g:pydoc = 'pydoc'
Default values:
" Load run code pluginlet g:pymode_run = 1" Key for run python codelet g:pymode_run_key = '<leader>r'
Default values:
" Load pylint code pluginlet g:pymode_lint = 1" Switch pylint or pyflakes code checker" values (pylint, pyflakes)let g:pymode_lint_checker = "pylint"" Pylint configuration file" If file not found use 'pylintrc' from python-mode plugin directorylet g:pymode_lint_config = "$HOME/.pylintrc"" Check code every savelet g:pymode_lint_write = 1" Auto open cwindow if errors be findedlet g:pymode_lint_cwindow = 1" Auto jump on first errorlet g:pymode_lint_jump = 0" Place error signslet g:pymode_lint_signs = 1" Minimal height of pylint error windowlet g:pymode_lint_minheight = 3" Maximal height of pylint error windowlet g:pymode_lint_maxheight = 6
Note
Pylint options (ex. disable messages) may be defined in$HOME/pylint.rc
See pylint documentation:http://pylint-messages.wikidot.com/all-codes
Default values:
" Load rope pluginlet g:pymode_rope = 1" Auto create and open ropeprojectlet g:pymode_rope_auto_project = 1" Enable autoimportlet g:pymode_rope_enable_autoimport = 1" Auto generate global cachelet g:pymode_rope_autoimport_generate = 1let g:pymode_rope_autoimport_underlineds = 0let g:pymode_rope_codeassist_maxfixes = 10let g:pymode_rope_sorted_completions = 1let g:pymode_rope_extended_complete = 1let g:pymode_rope_autoimport_modules = ["os","shutil","datetime"])let g:pymode_rope_confirm_saving = 1let g:pymode_rope_global_prefix = "<C-x>p"let g:pymode_rope_local_prefix = "<C-c>r"let g:pymode_rope_vim_completion = 1let g:pymode_rope_guess_project = 1let g:pymode_rope_goto_def_newwin = 0let g:pymode_rope_always_show_complete_menu = 0
Default values:
" Load motion pluginlet g:pymode_motion = 1" Load breakpoints pluginlet g:pymode_breakpoint = 1" Key for set/unset breakpointlet g:pymode_breakpoint_key = '<leader>b'" Autoremove unused whitespaceslet g:pymode_utils_whitespaces = 1" Auto fix vim python paths if virtualenv enabledlet g:pymode_virtualenv = 1" Set default pymode python indent optionslet g:pymode_options_indent = 1" Set default pymode python fold optionslet g:pymode_options_fold = 1" Set default pymode python other optionslet g:pymode_options_other = 1
Default values:
" Enable pymode's custom syntax highlightinglet g:pymode_syntax = 1" Enable all python highlightingslet g:pymode_syntax_all = 1" Highlight "print" as functionleg g:pymode_syntax_print_as_function = 0" Highlight indentation errorsleg g:pymode_syntax_indent_errors = g:pymode_syntax_all" Highlight trailing spacesleg g:pymode_syntax_space_errors = g:pymode_syntax_all" Highlight string formattingleg g:pymode_syntax_string_formatting = g:pymode_syntax_all" Highlight str.format syntaxleg g:pymode_syntax_string_format = g:pymode_syntax_all" Highlight string.Template syntaxlet g:pymode_syntax_string_templates = g:pymode_syntax_all" Highlight doc-testslet g:pymode_syntax_doctests = g:pymode_syntax_all" Highlight builtin objects (__doc__, self, etc)let g:pymode_syntax_builtin_objs = g:pymode_syntax_all" Highlight builtin functionslet g:pymode_syntax_builtin_funcs = g:pymode_syntax_all" Highlight exceptionslet g:pymode_syntax_highlight_exceptions = g:pymode_syntax_all" For fast machineslet g:pymode_syntax_slow_sync = 0
Note
Also you can see vim help:help PythonModeKeys
Keys | Command |
---|---|
K | Show python docs (g:pymode_doc enabled) |
<C-Space> | Rope autocomplete (g:pymode_rope enabled) |
<Leader>r | Run python (g:pymode_run enabled) |
<Leader>b | Set, unset breakpoint (g:pymode_breakpoint enabled) |
[[ | Jump on previous class or function (normal, visual, operator modes) |
]] | Jump on next class or function (normal, visual, operator modes) |
[m | Jump on previous class or method (normal, visual, operator modes) |
]m | Jump on next class or method (normal, visual, operator modes) |
ac | Select a class. Ex: vac, dac, yac, cac (normal, operator modes) |
ic | Select inner class. Ex: vic, dic, yic, cic (normal, operator modes) |
am | Select a function or method. Ex: vam, dam, yam, cam (normal, operator modes) |
im | Select inner function or method. Ex: vim, dim, yim, cim (normal, operator modes) |
Note
See also:help ropevim.txt
Note
Also you can see vim help:help PythonModeCommands
Command | Description |
---|---|
:Pydoc <args> | Show python documentation |
PyLintToggle | Enable, disable pylint |
PyLintCheckerToggle | Toggle code checker (pylint, pyflakes) |
PyLint | Check current buffer |
Pyrun | Run current buffer in python |
Note
See also:help ropevim.txt
To workrope creates a service directory:.ropeproject
.Ifg:pymode_rope_guess_project
set (by default) and.ropeproject
in current dir not found, rope scan.ropeproject
on every dir in parent path.If rope finded.ropeproject
in parent dirs, rope set project for all child dir and scan may be slow for many dirs and files.
Solutions:
- Disable
g:pymode_rope_guess_project
to make rope always create.ropeproject
in current dir. - Delete
.ropeproject
from dip parent dir to make rope create.ropeproject
in current dir. - Press
<C-x>po
or:RopeOpenProject
to make force rope create.ropeproject
in current dir.
In some projectspylint may check slowly, because it also scan imported modules if posible.Try usepyflakes, see:h 'pymode_lint_checker'
.
Note
You mayset exrc
andset secure
in yourvimrc
for auto set custom settings from.vimrc
from your projects directories.Example: On Flask projects I automaticly setg:pymode_lint_checker = "pyflakes"
, on djangog:pymode_lint_cheker = "pylint"
If you have any suggestions, bug reports orannoyances please report them to the issue trackerathttps://github.com/klen/python-mode/issues
Development of pylint-mode happens at github:https://github.com/klen/python-mode
Copyright (C) 2011 Kirill Klenov (klen)
- Rope
Copyright (C) 2006-2010 Ali Gholami Rudi
Copyright (C) 2009-2010 Anton Gritsay
- Pylint
- Copyright (C) 2003-2011 LOGILAB S.A. (Paris, FRANCE).http://www.logilab.fr/
- Pyflakes:
- Copyright (c) 2005 Divmod, Inc.http://www.divmod.com/
- Python syntax for vim
- Copyright (c) 2010 Dmitry Vasilievhttp://www.hlabs.spb.ru/vim/python.vim
Licensed under aGNU lesser general public license.
About
Vim python-mode. PyLint, Rope, Pydoc, breakpoints from box.
Resources
Uh oh!
There was an error while loading.Please reload this page.