Create a default comment header template in R?

前端 未结 3 1759
误落风尘
误落风尘 2021-02-04 10:36

Is it possible to create a default comment header template in R for all new scripts?

I generally include some standard info at the top of all my scripts and would like

3条回答
  •  旧时难觅i
    2021-02-04 11:20

    Following the suggestion from @lmo above, I created two new code snippets in RStudio by editing the snippets file located at Preferences > Code > Edit Snippets

    Note: Code below the snippet definition must be indented using tab and not two spaces

    Snippet 1: Comment header for new scripts

    snippet header_script
      ##################################################
      ## Project:
      ## Script purpose:
      ## Date:
      ## Author:
      ##################################################
    

    Snippet 2: Comment header for sections of code within a script:

    snippet header_section
      ## Section:
      ##################################################
    

    Now, whenever I want to insert a given header, I just start typing the snippet name (e.g. header_script), select it from the autocomplete menu (do not type out in full), and hit enter to insert the comment header.

提交回复
热议问题