简体   繁体   中英

Code Autoindentation in Rgui

Is there code autoindentation possible in the R for Windows - Rgui? Cannot find it in the options (see below). It is quite uncomfortable having to press [tab] several times at the beginning of every row :-/ :-)

PS: please do not advise to use Rstudio, I didn't like it :) I like the simplicity of Rgui.

在此处输入图片说明

You can batch reformat it with the formatR package.

Assuming that you are using the File | New window and entering the code in that window then after entering the code:

  1. select all your code (ctrl-a) and send it to the clipboard (ctrl-c) and then

  2. set focus to the R console and enter this which will reformat the code in the clipboard and replace it on the clipboard with the reformatted code. (If you have already done this previously in the session you can just uparrow and enter to retrieve and run the prior instance.)

     library(formatR) tidy_source(file = "clipboard") 
  3. finally set focus back to the code window, select everything (ctrl-a) and paste in the reformatted code (ctrl-v) to overwrite it with the reformatted code.

You could create an AutoHotKey script to automate the entire procedure but even if you don't it's only a few keystrokes or if you are using some text editor that you didn't mention there may be automation facilities in it.

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