3

How can I rename functions project wide?

I am using spacemacs and also with tern, and it look like tern can only rename variables.

2

Maybe you could try to use SPC p R which runs the command projectile-replace this might not be exactly what you want (a specific js refactor tool) but it gets the job done and is language agnostic.

Another more advanced option would be to search the name of that function with helm, once you are in the helm buffer C-c C-e runs helm-ag-edit, this will give you a buffer with your matches, in this buffer you can run iedit and rename that function across different files at once, you will need to C-c C-c to persist your changes though. I use this all the time (here the link where I first read about this https://gitter.im/syl20bnr/spacemacs?at=573d831c0cb634927f80545e)

1

There's the js2-refactor package which does many things but doesn't rename functions. Perhaps you could extend it.

  • Soon if I already learned to write emacs-lisp. – zer09 Jan 26 '18 at 2:45
  • If you do javascript, how did you do renaming functions? – zer09 Jan 26 '18 at 2:45
  • It honestly doesn't come up very often. When it does I just do it the old-fashioned way: rename the function and then go find the callers to change them to match. If it's a codebase I'm familar with then I probably know where all the callers are, and if it's one that I'm new to then I just use grep. – db48x Jan 27 '18 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.