Just select the entire block and copy it to the clipboard. Then call theFormatCommentfunction like this: And you will get the following output: # This is some text# I want to insert# as a comment# in the middle of# my R script....