Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Frozen String Literal RubyNew to Visual Studio Code? Get it now.
Frozen String Literal Ruby

Frozen String Literal Ruby

Sotiris Sotiriou

|
3 installs
| (0) | Free
This is an extension for automatically adding the frozen string literal comment at the top of ruby files
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Ruby: Frozen String Literal

Adds the Ruby magic comment # frozen_string_literal: true automatically to your Ruby files.

Features

This VS Code extension ensures that all your Ruby files include the # frozen_string_literal: true magic comment at the top of the file.

It works in two ways:

  • ✅ Automatic Insertion:

    • Adds the comment on file open and on save.
    • Skips if the file already includes the comment.
    • Preserves existing shebangs (#!/usr/bin/env ruby) or encoding comments by inserting after them.
  • 🔧 Manual Command:

    • Use the command palette (Cmd+Shift+P or Ctrl+Shift+P) and run:

      Ruby: Add `# frozen_string_literal: true`
      
    • The manual command works on any file. If it's not a Ruby file, you'll be prompted with an option to insert the comment anyway.

Extension Settings

You can disable the automatic behavior and use the manual command only:

"frozenStringLiteralRuby.enableAutoInsert": false

You can add paths of certain files or folders that you wish to be excluded from the automated insertion of the magic string

"frozenStringLiteralRuby.excludePaths": [
  "app/admin/",
  "lib/vendor/"
],

"frozenStringLiteralRuby.excludeFiles": [
  "lib/special_case.rb",
  "test/legacy_test.rb"
]

Examples

First example:

Given a file like this:

puts 'hello world'

The extension should update it to this:

# frozen_string_literal: true

puts 'hello world'

Second example:

Given a file like this:

#!/usr/bin/env ruby
# encoding: utf-8

puts 'hello world'

The extension should update it to this:

#!/usr/bin/env ruby
# encoding: utf-8
# frozen_string_literal: true

puts 'hello world'

Installation

Search for Frozen String Literal Ruby in the Extensions panel in VS Code and install it.

License

This extension is licensed under the MIT License. See the LICENSE file for details.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft