Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
vim Sync comments with plugins/README.rst Jan 9, 2018
README.rst Fix bugs of handling arrays in Feb 24, 2019


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.

You can’t perform that action at this time.