Refactoring R code using ESS/R

前端 未结 2 1214
盖世英雄少女心
盖世英雄少女心 2021-02-10 05:27

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.

2条回答
  •  一向
    一向 (楼主)
    2021-02-10 06:11

    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.

提交回复
热议问题