Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

15 Commits

Repository files navigation

python-vim

Little vim plugin for python

Installation

git clone https://github.com/kimbo/vim-python.git ~/.vim/pack/plugins/start/vim-python

Usage

The suggested way to use vim-python is to define some mappings in your ~/.vimrc:

autocmdBufNewFile,BufReadPost*.pynnoremap<F3>:PySetArgs <CR>autocmdBufNewFile,BufReadPost*.pynnoremap<F4>:PyBreakpoint <CR>autocmdBufNewFile,BufReadPost*.pynnoremap<F5>:PyRun <CR>autocmdBufNewFile,BufReadPost*.pynnoremap<F6>:PyRunWithArgs <CR>autocmdBufNewFile,BufReadPost*.pynnoremap<c-_>:PyCommentNormal <CR>autocmdBufNewFile,BufReadPost*.pyxnoremap<c-_>:PyCommentVisual <CR>

You can customize these to map to whatever keys you want.

After that, open up a Python file and start trying out the functions in the next section.

Functions

Here's a table that describes the functions that vim-python provides.

Function nameDescriptionSuggested mapping from above
:PySetArgsSet the arguments to be used when :PyRun is invokedF3
:PyBreakpointToggle a breakpoint on/above the current line. This just inserts import pdb; pdb.set_trace()F4
:PyRunRun the current file as a Python script. If ./venv/bin/python exists, it will be the interpreter chosen. Otherwise, the default python is usedF5
:PyRunWithArgsSet the arguments to be run, and then run the current file as a Python script. This combines :PySetArgs and :PyRun for convenienceF6
:PyCommentNormal and :PyCommentVisualToggle comment on the current line or visual selectionCtrl+/

Helpful tips

  • After running :PySetArgs or PyRunWithArgs, those args will be used as the default arguments until you exit vim or change the arguments
  • To quickly modify your previous arguments (e.g. to add an extra --some-param), run :PySetArgs or :PyRunWithArgs and then use the up arrow to view previous args.

About

👶 lightweight vim plugin for python

Topics

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages