3

When I run brew edit _some_formula_, it opens up vim. I tried changing the $EDITOR variable of my terminal to emacs, but it still uses vim. How can I change the editor that brew uses when calling brew edit?

1 Answer 1

5

Homebrew searches for your editor in the environment variables HOMEBREW_EDITOR, VISUAL, and EDITOR in that order. If none of these are defined, Homebrew will try to use, in order: TextMate, TextWrangler, or the system install of Vim.

Built-in Homebrew commands are defined in /usr/local/Library/Homebrew/cmd, assuming a default install location. Examining edit.rb in that folder we see that the editor is located with the function which_editor. Grepping for which_editor brings us to utils.rb:

def which_editor
  editor = ENV.values_at('HOMEBREW_EDITOR', 'VISUAL', 'EDITOR').compact.first
  # If an editor wasn't set, try to pick a sane default
  return editor unless editor.nil?

  # Find Textmate
  return 'mate' if which "mate"
  # Find BBEdit / TextWrangler
  return 'edit' if which "edit"
  # Default to vim
  return '/usr/bin/vim'
end

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .