Multiline Comment Workarounds?

后端 未结 10 1124
轮回少年
轮回少年 2020-11-30 18:36

I (sort of) already know the answer to this question. But I figured it is one that gets asked so frequently on the R Users list, that there should be one solid good answer.

10条回答
  •  悲&欢浪女
    2020-11-30 19:07

    I use vim to edit the R script.

    Let's say the R script is test.R, containing say "Line 1", "Line 2", and "Line 3" on 3 separate lines.

    I open test.R on the command line with Vim by typing "vim test.R". Then I go to the 1st line I want to comment out, type "Control-V", down arrow to the last line I want to comment out, type a capital I i.e. "I" for insert, type "# ", and then hit the Escape key to add "# " to every line that I selected by arrowing down. Save the file in Vim and then exit Vim by typing ":wq". Changes should show up in Rstudio.

    To delete the comments in Vim, start at the first line on top of the character "#" you want to delete, again do "Control-V", and arrow down to the last line you want to delete a "#" from. Then type "dd". The "#" signs should be deleted.

    There's seconds-worth of lag time between when changes to test.R in Vim are reflected in Rstudio.

提交回复
热议问题