-
Notifications
You must be signed in to change notification settings - Fork 436
Link to your editor
Better Errors includes a link to the source code when you're looking at any exception.

By default, your EDITOR environment variable is used to determine which editing application you prefer.
If you haven't set EDITOR, that would be a good first step for making development easier.
Some editors require you to take steps to install their command-line tool, and then you'll need to modify your ~/.bashrc (stock macOS) or ~/.zshconfig (if you use ZSH).
If you are using Pow, a tool for managing multiple web applications on Mac, see these instructions to configure Pow.
If you are using Vagrant, Docker, or another virtualization mechanism, you may need to configure it to have the correct location of the source files on your machine. See Running on virtual machines.
You can configure your Ruby project to force Better Errors to link to a specific editor, but this is not recommended, since each developer on your project may prefer a different editor.
If you want to do this even though it is not recommended, in a Rails project, place this in config/environments/development.rb:
if defined? BetterErrors
# Force all developers on this project to use Textmate, even if they prefer something else.
BetterErrors.editor = :txmt
endor if you are using an editor that is not supported directly by Better Errors, you can use:
if defined? BetterErrors
# Force all developers on this project to use VS Code, even if they prefer something else.
BetterErrors.editor = "vscode://open?url=file://%{file}&line=%{line}"
endBetter Errors supports the following editors:
This is enabled if $EDITOR contains "emacs".
The URL is emacs://open?url=file://%{file}&line=%{line}.
You'll need to register the emacs:// protocol in Firefox.
Also, Firefox will pass a lot of junk to the command, here's a suggestion for your bin/ folder: https://gist.github.com/nofxx/6987409
This is enabled if $EDITOR contains "idea".
The URL is idea://open?file=%{file}&line=%{line}.
This is enabled if $EDITOR contains "vim".
The URL is mvim://open?url=file://%{file}&line=%{line}.
Instructions are in phallstrom/urlscheme_vim_in_iterm.
This is enabled if $EDITOR contains "rubymine".
The URL is rubymine://open?file=%{file}&line=%{line}.
This is enabled if $EDITOR contains "subl".
The URL is subl://open?url=file://%{file}&line=%{line}.
Add the following to your shell config:
export EDITOR="mate -w"You'll need to install subl handler or something similar.
If you installed a sublime URL handler before August 2017, please see this security advisory and remove your old URL handler.
This is enabled by default, or if $EDITOR contains "mate".
The URL is txmt://open?url=file://%{file}&line=%{line}.
Add the following to your shell config:
export EDITOR="mate -w"(The -w causes the command line tool to wait until you close the file before it continues.
This is necessary for tools like git, where it must wait for you to edit the file before continuing.)
Support for these should be added to Better Errors soon.
(Currently Atom uses the atom:// scheme, but it does not properly handle it.
Until the project fixes this issue, it is necessary to use a different scheme and install a custom URL handler.)
Place this in config/environments/development.rb:
BetterErrors.editor='atm://open?url=file://%{file}&line=%{line}' if defined? BetterErrorsYou will need to install one of the following:
- WizardOfOgz/atom-handler for macOS
- UziTech/atom-url-handler for Windows
- eclemens/atom-url-handler for Linux
Place this in config/environments/development.rb:
BetterErrors.editor='x-mine://open?file=%{file}&line=%{line}' if defined? BetterErrorsSet up the following config:
BetterErrors.editor = "vscode://open?url=file://%{file}&line=%{line}" if defined? BetterErrorsYou'll need to install the vscode-handler extension.