Skip to content

Instantly share code, notes, and snippets.

@alissonbrunosa
Created December 29, 2021 14:52
Show Gist options
  • Save alissonbrunosa/4262bc0ecd36b3c4fdd6c09300e7cb96 to your computer and use it in GitHub Desktop.
Save alissonbrunosa/4262bc0ecd36b3c4fdd6c09300e7cb96 to your computer and use it in GitHub Desktop.
Open constants and methods in Vim.
# frozen_string_literal: true
if Rails.env.development?
ActiveSupport::Reloader.to_prepare do
module OpenOnVim
def open_method(method_name)
file, line = method(method_name.to_sym).source_location
vim(file, line)
end
def open_const(name)
file, line = Object.const_source_location(name)
vim(file, line)
end
def vim(file, line)
return false if file.nil? || line.nil?
system("vimx --remote #{file}") && system("vimx --remote-send ':#{line}<CR>'")
end
end
class Object
include OpenOnVim
extend OpenOnVim
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment