ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Beautify​Ruby

by CraigWilliams ALL

Sublime Text 2 & 3 Plugin to Beautify Ruby

Details

  • 2020.08.07.01.43.58
  • github.​com
  • github.​com
  • 1 year ago
  • 13 minutes ago
  • 10 years ago

Installs

  • Total 67K
  • Win 16K
  • Mac 32K
  • Linux 18K
Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4 Sep 3 Sep 2 Sep 1 Aug 31 Aug 30 Aug 29 Aug 28 Aug 27 Aug 26 Aug 25 Aug 24 Aug 23 Aug 22 Aug 21 Aug 20 Aug 19 Aug 18 Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12 Aug 11 Aug 10 Aug 9 Aug 8 Aug 7 Aug 6 Aug 5
Windows 1 1 1 2 0 1 3 1 5 2 2 3 3 3 0 0 3 2 3 0 3 2 0 1 1 1 1 0 0 1 1 2 3 3 4 1 2 3 4 1 2 2 3 0 0 0
Mac 1 0 0 7 4 4 1 0 0 3 1 8 2 0 1 2 3 4 1 3 4 0 3 1 3 4 2 2 2 1 3 0 2 3 2 1 1 1 4 5 4 1 1 3 1 6
Linux 0 1 4 2 0 0 4 3 0 0 1 3 3 1 1 0 3 0 1 1 0 1 1 0 0 1 1 0 0 0 0 0 0 4 1 1 0 4 2 0 3 0 0 1 0 3

Readme

Source
raw.​githubusercontent.​com

Codeship Status for CraigWilliams/BeautifyRuby

BeautifyRuby

Erb html templates uses Paul Battley's htmlbeautifier gem. This (as well as rubygems) is assumed to be installed as seen by the ruby interpreter. Note that if you beautify an erb file but htmlbeautifier is not found, the error message is 'check your ruby interpreter settings', do not be misled.

Interpreter settings

If an error is encountered while processing the file, Python receives an empty string and the following message is displayed but may have nothing to do with your Ruby settings.

check your ruby interpreter settings

Hooks

This package offers a pre-save hook, i.e., your ruby and erb files will be reformatted automatically before saving. To activate this feature, set:

"run_on_save": true,

The sublime command “beautify_ruby” performs a save after formatting. You can disable this default by setting:

"save_on_beautify": false

You can change the file patterns handled by this plugin in the settings:

"file_patterns": [ "\\.html\\.erb", "\\.rb", "\\.rake", "Rakefile", "Gemfile" ],
"html_erb_patterns": ["\\.html\\.erb"],

This plugin uses ruby scripts to beautify your buffer, so it needs ruby installed. You can configure your ruby interpreter under Preferences -> Package Settings -> BeautifyRuby -> Settings Default/User click here for a screenshot. Although the default should work on linux and osx, not setting this right is a common problem.

If you do not use the system ruby, type in your favourite shell:

which ruby

and place that in the ruby setting.

On windows, set Preferences -> Package Settings -> BeautifyRuby -> Settings Default

"ruby": "ruby"

If you use project-specific rubies and gem sets managed with rvm, then simply set

"ruby": "~/.rvm/bin/rvm-auto-ruby",

and then the htmlbeautifier gem is found even if it is only installed for this project.

If you are using ruby on the Windows Subsystem for Linux, use:

"ruby": "wsl ruby"

Tabs or Spaces

By default, Sublime does not translate tabs to spaces. If you wish to use tabs you will not need to change your settings. If you wish to use spaces, add the following setting.

"translate_tabs_to_spaces": true

Or if you wish to force the use of tabs use:

"translate_tabs_to_spaces": false

Tab size

Sublime's default tab_size is set to 4. Override this setting to change the number of spaces to use when using spaces instead of tabs.

"tab_size": 2

Key Binding

ctrl + cmd + k on OS X, or ctrl + alt + k on Windows

Installation

Package Control

Using Package Control, a package manager for Sublime Text 2.

In ST2, press “cmd + shift + p” and then type “install”.

Once you see “Package Control: Install Package”, enter.

When the packages load, another selection window will appear. Type

BeautifyRuby and enter. All done!

Manual Installation

cd "~/Library/Application Support/Sublime Text 2/Packages/"
  git clone git://github.com/CraigWilliams/BeautifyRuby.git