Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

rubyfmt

> 编程语言
Open source

Ruby Autoformatter!

1.2K stars0 likes1 views
WebsiteGitHub

About

Ruby Autoformatter!

rubyfmt

A fast, opinionated Ruby formatter written in Rust.

  • Try it online → rubyfmt.run

Pronunciation: (en) "Ruby Format", (jp) ルビーフォーマット

Quick Start

bash
# Install
brew install rubyfmt

# Format a file in place
rubyfmt -i myfile.rb

# Format and print to stdout
rubyfmt myfile.rb

Installation

Homebrew

bash
brew install rubyfmt

Build from Source

  1. Make sure you have Cargo installed
  2. Run cargo build --release
  3. Copy target/release/rubyfmt-main to somewhere on your path as rubyfmt

Usage

Command Line

Command Description
rubyfmt file.rb Output formatted code to stdout
rubyfmt -i file.rb Format file in place
rubyfmt -c file.rb Show diff of changes
cat file.rb | rubyfmt Read from stdin

You can also pass directories to format multiple files at once.

For the full command line interface, see rubyfmt --help.

Header Comments

Control formatting on a per-file basis with header comments:

  • rubyfmt --header-opt-in - Only format files with # rubyfmt: true at the top
  • rubyfmt --header-opt-out - Skip files with # rubyfmt: false at the top

Ignoring Files

Create a .rubyfmtignore file in your project root to exclude files from formatting. It uses the same syntax as .gitignore.

By default, rubyfmt also respects your .gitignore. Use --include-gitignored to format those files anyway.

Editor Integration

Visual Studio Code

The popular ruby-lsp extension has a rubyfmt add-on. Install the extension:

bash
# Add to project
bundle add ruby-lsp-rubyfmt-formatter --group development

# Install globally
gem install ruby-lsp-rubyfmt-formatter

And then add the following to your .vscode/settings.json:

json
{
  "[ruby]": {
    "editor.defaultFormatter": "Shopify.ruby-lsp",
    "editor.formatOnSave": true
  },
  "rubyLsp.formatter": "rubyfmt"
}

Rubyfmt is also supported by the (now-deprecated) VSCode Ruby extension. Add the following to your settings.json:

json
{
  "ruby.useLanguageServer": true,
  "ruby.format": "rubyfmt",
  "[ruby]": {
    "editor.formatOnSave": true
  }
}

This is additionally supported by the Formatto for VS Code extension. Use it as your project's formatter by adding this entry to your .vscode/settings.json after installing the extension:

jsonc
{
  "[ruby]": {
    "editor.defaultFormatter": "damolinx.formatto"
  },
}

Check its README for additional configuration options.

Neovim + null-ls

The null-ls plugin supports rubyfmt out of the box:

lua
null_ls.setup({
  sources = {
    null_ls.builtins.formatting.rubyfmt,
  },
})

See the null-ls documentation for more details.

Vim

vim-plug:

vim
Plug 'fables-tales/rubyfmt', { 'rtp': 'editor_plugins/vim' }

Native packages:

bash
git clone https://github.com/fables-tales/rubyfmt ~/.rubyfmt
ln -s ~/.rubyfmt/editor_plugins/vim ~/.vim/pack/rubyfmt/start/rubyfmt

Set g:rubyfmt_path if rubyfmt is not on your $PATH.

RubyMine (and JetBrains IDEs)

  1. Install the File Watchers plugin
  2. Go to File | Settings | Tools | File Watchers
  3. Import watchers.xml
  4. Optionally set Level to Global for all projects

See the File Watchers documentation for more details.

Sublime Text

Install the rubyfmt plugin via Package Control.

Files format on save or with Cmd + ; (macOS) / Alt + ; (other). Settings:

json
{
  "ruby_executable": "ruby",
  "rubyfmt_executable": "rubyfmt",
  "format_on_save": true
}

Atom

Install the rubyfmt package from Settings > Packages.

Files format on save or with Cmd + ; (macOS) / Alt + ; (other).

Rubocop

For usage with Rubocop, see the rubocop-rubyfmt gem.

Contributing

Please check out our contributing guide.

Maintenance Status

The original author (fables-tales) is no longer working on open source in their spare time. Other contributors work regularly on rubyfmt, and contributors with commit access are welcome to merge changes that pass CI.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言