Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 225
nsheff Avatar asked Jun 14 '17 21:06

nsheff


1 Answers

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 PackageResourceViewer
  2. Open the command palette
  3. Type PRV: O
  4. Select PackageResourceViewer: 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 #
like image 65
Keith Hall Avatar answered Oct 12 '22 13:10

Keith Hall