Editor Integration
April 30, 2026 ยท View on GitHub
If your favourite editor is not listed here, we would love to receive a PR with how to include it.
Unless otherwise specified, all instructions assume you have snakefmt installed
already.
Table of Contents
PyCharm/JetBrains IDEA
- Locate the path to your
snakefmtexecutable.
# linux and macOS
$ which snakefmt
/usr/local/bin/snakefmt # just an example
# windows
$ where snakefmt
%LocalAppData%\Programs\Python\Python36-32\Scripts\snakefmt.exe # just an example
- Open External tools in PyCharm/IntelliJ IDEA
-
On macOS:
PyCharm -> Preferences -> Tools -> External Tools -
On Windows / Linux / BSD:
File -> Settings -> Tools -> External Tools
-
Click the
+icon to add a new external tool with the following values:- Name: Snakefmt
- Description: The uncompromising Snakemake code formatter
- Program: result of
which/where snakefmtfrom step 1 - Arguments:
"$FilePath$"
-
Format the currently opened file by selecting
Tools -> External Tools -> Snakefmt.- Alternatively, you can set a keyboard shortcut by navigating to
Preferences/Settings -> Keymap -> External Tools -> External Tools - Snakefmt. We use Alt+s
- Alternatively, you can set a keyboard shortcut by navigating to
-
Optionally, run
snakefmton every file save:- Make sure you have the File Watchers plugin installed.
- Go to
Preferences or Settings -> Tools -> File Watchersand click+to add a new watcher:- Name: Snakefmt
- File type: Python
- Scope: Project Files
- Program: result of
which/where snakefmtfrom step 1 - Arguments:
$FilePath$ - Output paths to refresh:
$FilePath$ - Working directory:
$ProjectFileDir$
- Uncheck "Auto-save edited files to trigger the watcher" in Advanced Options
Visual Studio Code
-
Install the extension within Visual Studio (VS) Code by visiting the Snakefmt extension page and following the instructions at the top of the page.
-
Follow the directions under the extension's Details page. Pay attention in particular to the Requirements section to provide a path to your
snakefmtexecutable (if it isn't already in yourPATHenvironment variable). -
See VS Code's documentation on Formatting for more instructions on how to apply formatting within the IDE.
Vim / Neovim
Neovim (Recommended)
A modern Lua-based plugin for Neovim 0.10+ that provides asynchronous, non-blocking formatting.
Features
- Fast formatting using
vim.system. - Automatic fallback to
uv run --with snakefmt snakefmtifsnakefmtis not in your environment. - Configurable line length and auto-format on save.
Installation (with lazy.nvim)
{
"snakemake/snakefmt",
ft = { "snakemake" },
config = function()
require("snakefmt").setup({
-- auto_format = true, -- uncomment to enable auto-format on save
})
end,
}
Usage
:Snakefmt: Format the current buffer.:SnakefmtInfo: Show whichsnakefmtbinary is being used.
Vim (Legacy)
Credit: plugin inspired by black
-
Install the plugin using a manager like vim-plug:
Plug 'snakemake/snakefmt' -
Run
:Snakefmtto format a buffer, and:SnakefmtVersionfor version info. Note: Requires Vim 7.0+ with Python 3.6+ support. -
To format automatically on save, add to your
vimrc:au BufNewFile,BufRead Snakefile,*.smk set filetype=snakemake au FileType snakemake autocmd BufWritePre <buffer> execute ':Snakefmt'
Syntax Highlighting
For syntax highlighting in both Vim and Neovim, install the Snakemake syntax highlighter.
emacs
The format-all package supports use of snakefmt out of the box provided snakefmt is available on the exec-path; it should suffice to have snakefmt available on your PATH.
snakefmt can be invoked in a buffer using format-all in the usual way with format-all-buffer, and also by adding a hook to your dotfile to enable the format-all-mode minor mode. If you are using snakemake-mode already, you can do this with:
(add-hook `snakemake-mode-hook #`format-all-mode)
See the format-all repo for more documentation.