Search code examples
commentssublimetext2togglesyntax-highlightingtmlanguage

How do I get comment toggle to work with my own tmLanguage syntax for Sublime Text 2?


I made my own syntax highlighting (for a language using c++ code with some additional keywords) by copying and editing the C.tmLanguage file.

I did not edit any of the "comments" keys, but now the comment toggle in ST2 does not work. (I think it did at first, and the highlighting does work, but neither the "Toggle Comment" or the "Toggle Block Comment" works)

My .tmLanguage file is placed in Packages/User.


Solution

  • You need to define TM_COMMENT_START (and TM_COMMENT_START2/TM_COMMENT_END2) in tmPreferences

    for a sample see https://github.com/laktak/sublime-hjson/blob/master/Comments.tmPreferences