Rmarkdown comment out in BASH code using "#"

In Rmarkdown, I can use cmd+shift+c to comment out a trunk of code with "#". Like

options(scipen = 999)

# Ne = 1*10^6
# len = 55000

But in BASH code, when I use cmd+shift+c, it comments the code with "", rather than "#".

<!-- create_ann() { -->
<!--   scfid=${1%%.*} -->
<!--   echo ${vcfname} -->
<!--   java -jar xx.jar -->
<!-- } -->

In fact, "<!--" doesn't act as comments in terminal. So how can I comment bash code with "#" using shortcuts.

1 Like

I can reproduce this behavior.

it seems RStudio to recognize the bash chunks and does not know how to comment those lines in this type of chunk.

I think this is something to report in RStudio IDE issue as a feature request. I did not find it yet (see https://github.com/rstudio/rstudio/issues)
I don't think there is something to be done in Rmarkdown for this IDE behavior

To comment those lines, you need to do it manually with #. You can get help with multiline selection shortcut (CTRL + ALT + down (or up)) ;This will duplicate the cursor many times and fill in all when you'll type #


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.