简体   繁体   中英

Refactoring R code using ESS/R

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.

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.

  • Cx d (enter dired)

  • % mr$ (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 .

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM