-
Notifications
You must be signed in to change notification settings - Fork 437
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.
If you prefer that Better Errors use a different editor than the one in your $EDITOR
, set the $BETTER_ERRORS_EDITOR
environment variable.
It will take precedence.
(But this is supported only by v2.9 and higher.)
Some editors require you to take steps to install their command-line tool.
Then you'll need to modify your ~/.bashrc
or ~/.zshrc
depending on which shell you use, to set $EDITOR
.
If you are using Pow or puma-dev for managing multiple web applications see Running in Puma dev or 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.
If your editor is not supported, we strongly recommend against modifying your software project to point to a specific editor. This is because every developer might have different preferences.
Better Errors supports the following editors.
See
BetterErrors::Editor::KNOWN_EDITORS
for more information. If your$EDITOR
matches thesniff
pattern, the listed editor will be used.
If your editor is not listed, you can instead set
$BETTER_ERRORS_EDITOR_URL
to a string like theurl
s listed there. By doing this, you can customize the URL to anything you want, including cloud editors. (But this is supported only by v2.9 and higher.)
Atom v1.23 added support for open/file URLs.
Install the Shell Commands from within Atom and add the following to your shell config:
export EDITOR="atom"
Add the following to your shell config:
export EDITOR="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
Add the following to your shell config:
export EDITOR="idea"
The URL is idea://open?file=%{file}&line=%{line}
.
Add the following to your shell config:
export EDITOR="vim"
The URL is mvim://open?url=file://%{file}&line=%{line}
.
Instructions are in phallstrom/urlscheme_vim_in_iterm.
In newer version of RubyMine you have to enable the Command-Line Launcher. This can be done via the Jetbrains Toolbox App.
Add the following to your shell config:
export EDITOR="rubymine"
The URL is rubymine://open?file=%{file}&line=%{line}
.
If this doesn't work, you can instead use the "Forcing a specific editor" method (see below) with 'x-mine://open?file=%{file}&line=%{line}'
.
You'll need to install subl handler or something similar.
Add the following to your shell config:
export EDITOR="subl -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.)
If you installed a sublime URL handler before August 2017, please see this security advisory and remove your old URL handler.
The URL is subl://open?url=file://%{file}&line=%{line}
.
TextMate-compatible URLs are 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.)
Install the command-line tools
Add the following to your shell config (on MacOS put this in ~/.bash_profile :
export EDITOR="code --wait"
(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.)
For VS Code remote targets under WSL, the following initializer works (see below):
if defined?(BetterErrors) && (distro_name = ENV['WSL_DISTRO_NAME'])
BetterErrors.editor = "vscode://vscode-remote/wsl+#{distro_name}%{file_unencoded}:%{line}"
end
Is your preferred editor missing? Please open an Issue or Pull Request.
Nova does not currently support opening files through a nova://
scheme URL.
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 must configure Better Errors this way, add config/initializers/better_errors.rb
to your global .gitignore or the project .gitignore
file.
Place the following in config/initializers/better_errors.rb
:
if defined?(BetterErrors)
BetterErrors.editor = :txmt
end
If you're using an editor that is not supported directly by Better Errors, you can provide a formatting string, for example:
if defined?(BetterErrors)
BetterErrors.editor = "vscode://file/%{file}:%{line}"
end
Or if you need to change the way the string is assembled, you can provide a proc, for example:
if defined?(BetterErrors)
BetterErrors.editor = proc { |file, line|
"vscode://file/%{file}:%{line}" % { file: URI.encode_www_form_component(file), line: line }
}
end