Refactoring R code using ESS/R

强颜欢笑 提交于 2019-12-21 02:28:10

问题


I would like to know if it is possible to refactor R code in ESS. Using search and replace in Emacs does not seem to be a good alternative to it.


回答1:


ESS itself does not provide any facilities for refactoring. Instead you can use emacs functionality.

Here is an example of how to replace all words starting with "xxx" and ending with "yyy" with "zzzzzz" in all your open R files in your project directory.

  • C-x d (enter dired)

  • % m r$ (mark all files ending in R or r)

  • Q (enter dired-to-query-replace-regexp)
  • type xxx.*zzz and zzzzzz when asked for replacement patterns.
  • accept, skip with y,n

Here is a complete tutorial of how to search-replace in multiple files. and also how to save all modified buffers with ibuffer.




回答2:


In Emacs you can do a search replace with M-% and then ! will replace every instance in the current buffer.

If that isn't want you mean, can you explain (edit your Q or comment here) what Statet does and what exactly you'd like to do in Emacs + ESS?



来源:https://stackoverflow.com/questions/2978753/refactoring-r-code-using-ess-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!