You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Bill Wendling 503bc40d60 Rename master branch to main 2 years ago
vim Sync comments with plugins/README.rst 5 years ago
README.rst Rename master branch to main 2 years ago Fix bugs of handling arrays in 4 years ago


IDE Plugins


The Emacs plugin is maintained separately. Installation directions can be found here:


The vim plugin allows you to reformat a range of code. Copy plugin and autoload directories into your ~/.vim or use :packadd in Vim 8. Or use a plugin manager like Plug or Vundle:

" Plug
Plug 'google/yapf', { 'rtp': 'plugins/vim', 'for': 'python' }

" Vundle
Plugin 'google/yapf', { 'rtp': 'plugins/vim' }

You can add key bindings in the .vimrc file:

map <C-Y> :call yapf#YAPF()<cr>
imap <C-Y> <c-o>:call yapf#YAPF()<cr>

Alternatively, you can call the command YAPF. If you omit the range, it will reformat the whole buffer.


:YAPF       " formats whole buffer
:'<,'>YAPF  " formats lines selected in visual mode

Sublime Text

The Sublime Text plugin is also maintained separately. It is compatible with both Sublime Text 2 and 3.

The plugin can be easily installed by using Sublime Package Control. Check the project page of the plugin for more information:

git Pre-Commit Hook

The git pre-commit hook automatically formats your Python files before they are committed to your local repository. Any changes yapf makes to the files will stay unstaged so that you can diff them manually.

To install, simply download the raw file and copy it into your git hooks directory:

# From the root of your git project.
curl -o
chmod a+x
mv .git/hooks/pre-commit

Textmate 2

Plugin for Textmate 2 requires yapf Python package installed on your system:

pip install yapf

Also, you will need to activate Python bundle from Preferences >> Bundles.

Finally, create a ~/Library/Application Support/TextMate/Bundles/Python.tmbundle/Commands/YAPF.tmCommand file with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">


"$TPY" "/usr/local/bin/yapf" "$TM_FILEPATH"</string>

You will see a new menu item Bundles > Python > YAPF.