I am new to Ruby. I am using Visual Studio Code and was wondering if there is a formatter (like the extension Prettier) for Ruby. I would like to use it to indent properly, etc.
Thank you!
Provides enhanced Ruby language and debugging support for Visual Studio Code. A language server that provides intellisense, code completion and inline documentation for Ruby. Ruby Solargraph is an absolute must and cements Visual Studio Code as one of the top ruby editors.
The code formatting is available in Visual Studio Code (VSCode) through the following shortcuts or key combinations: On Windows Shift + Alt + F. On macOS Shift + Option + F. On Linux Ctrl + Shift + I.
To run prettier with the Ruby plugin, you're going to need ruby (version 2.7. 3 or newer) and node (version 8.3 or newer). If you're integrating with a project that is not already using prettier , you should use the Ruby gem. Otherwise you can use the npm package directly.
Prettier is an opinionated code formatter which ensures one unified code format. It can be used in VS Code by installing it from the VS Code Marketplace. Once you have integrated it in VS Code, you can configure Prettier to format your files when saving them or committing them to a version control system (e.g. Git).
Prettier does support Ruby with the plugin-ruby [1] installed but the installation is a little bit tricky. You have to install the Prettier-Ruby-Plugin inside the vscode prettier extensions directory:
cd ~/.vscode/extensions/esbenp.prettier-vscode-1.8.1/
npm install @prettier/plugin-ruby
[1] https://github.com/prettier/plugin-ruby
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With