sublimetext3roxygen2

In Sublime Text 3, how can I change the comment character?


I like the auto-comment feature Ctrl + /, but I'd like to be able the change the character it uses arbitrarily. I have read many similar questions like this one, but it's not exactly a generic solution.

How can I make the comment character use something different? The specific use case is that I'm writing R code and using Roxygen2 for documentation. This uses #' as the comment character, instead of just #. So I I'd like to set sublime to use #' because as is, I can't use it for Roxygen2 comments.

Questions regarding Sublime2, like this one, refer to '.tmPreferences' files, but I have not been able to find any such files in my Sublime 3 installation. If the answer is still these files, where are they stored in Sublime 3?


Solution

  • As mentioned in Enable automatic commenting in Sublime Text for a custom syntax, .tmPreferences files are used to specify what the comment markers are for a syntax.

    To edit the comment markers for R:

    1. Install OverrideAudit
    2. Open the command palette
    3. Type OA:OR
    4. Select OverrideAudit: Open Resource
    5. Select R
    6. Select Comments.tmPreferences
    7. Edit the TM_COMMENT_START value to #' as desired
    8. Save the file
    9. Use the toggle comment functionality on an R file and see that it now uses #' instead of #