DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk3 min

How to Configure rubyfmt and Format Only Selected Files

Run rubyfmt on only the Ruby files you choose with explicit paths, ignore rules, header controls, or Formatto’s changed-file command.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To format just a few Ruby files with rubyfmt, pass their paths explicitly: rubyfmt -i lib/a.rb lib/b.rb. The -i flag formats those files in place. For broader runs, use .rubyfmtignore and rubyfmt’s Git-ignore or header controls to limit what it touches. Choosing files is different from formatting selected lines inside a file; the latter is experimental in the Formatto VS Code extension.

Install rubyfmt

rubyfmt is described by its project README as “A fast, opinionated Ruby formatter written in Rust.” The project documents installation with Homebrew or by building from source with Cargo and putting the resulting executable on your PATH. See the official rubyfmt README for the current instructions. Homebrew also lists rubyfmt as a Ruby autoformatter and links to the project: rubyfmt on Homebrew.

Format only named files from the command line

Pass the exact file paths you want to process. For example, rubyfmt -i lib/a.rb lib/b.rb formats only those two files in place. If you omit -i, rubyfmt file.rb writes formatted output to standard output instead of replacing the file. Use -c to see a diff rather than applying the formatting.

The same path-based approach works when you want a small, explicit set of files: provide each path as an argument rather than passing a project directory. The README also documents passing directories to process multiple files, which is useful for a broader pass but less precise when you want to avoid touching unrelated code.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall

Limit directory-wide formatting with ignore rules

When you pass a directory, rubyfmt respects Git ignore rules by default. To add rubyfmt-specific exclusions, create a root-level .rubyfmtignore file using .gitignore syntax. Files already ignored by Git are normally omitted; add --include-gitignored when you explicitly want rubyfmt to include them.

This is a useful distinction: named paths define a narrow run directly, while ignore rules help constrain discovery when you intentionally process a directory. Check the project README for the current command-line behavior and available options.

Opt files in or out with header comments

For repository-level file-by-file control, rubyfmt supports header comments when you activate the matching CLI option:

  • --header-opt-in formats files that begin with # rubyfmt: true.
  • --header-opt-out skips files that begin with # rubyfmt: false.

The comments alone do not activate these policies; use the corresponding option on the rubyfmt command. Consult the README for the exact invocation supported by your installed version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Format changed files in VS Code with Formatto

The Formatto extension supports rubyfmt and provides a “Format Pending Changes” command for modified Ruby files in open Git repositories. The operation works on files on disk, so save unsaved edits before running it. For an individual document, configure Formatto and use VS Code’s Format Document command or Format on Save.

Formatto defaults to rubyfmt. Its settings let you choose a formatter, set formatto.rubyfmtPath, add rubyfmt arguments such as --header-opt-in, and define exclusions with formatto.excludePatterns. The extension lists .rb, .rbs, .rbi, .gemspec, and .podspec as supported rubyfmt extensions. See the Formatto extension listing for its documentation and current settings.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Can rubyfmt format only selected lines?

That is a different task from selecting files. Formatto’s range-formatting support is experimental and heuristic, not a dependable promise to format any arbitrary selection. Incomplete or syntactically broken ranges may remain unchanged, and range output can differ from formatting a complete document. Ruby formatters generally expect complete, syntactically valid code, according to the extension documentation.

If you need reliable, reproducible formatting, format the whole file and limit the command to the intended file paths. For editor range formatting, treat the result as best-effort and review the diff.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Is there a rubyfmt style configuration file?

The official README reviewed for this article does not document a general style configuration file. Its documented controls for limiting work are paths and directories, ignore rules, Git-ignore behavior, and optional header comments. Do not assume that a .rubyfmt.yml file is supported: the similarly named rfmt project is a different formatter.

Because command options and editor settings can change, check the CLI help and extension documentation for the versions you have installed.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.