在 Sublime Text 3 中,如何更改注释字符? [英] In Sublime Text 3, how can I change the comment character?
问题描述
我喜欢自动评论功能 Ctrl +/
,但我希望能够任意更改它使用的字符.我读过很多类似的问题,比如这个,但这并不是一个通用的解决方案.
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.
如何让评论字符使用不同的东西?具体用例是我正在编写 R 代码并使用 Roxygen2 作为文档.这使用 #'
作为注释字符,而不仅仅是 #
.所以我想将 sublime 设置为使用 #'
因为按原样,我不能将它用于 Roxygen2 注释.
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.
关于 Sublime2 的问题,例如这个,请参阅.tmPreferences"文件,但我在我的 Sublime 3 安装中找不到任何此类文件.如果答案仍然是这些文件,那么它们在 Sublime 3 中存储在哪里?
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?
推荐答案
如 在 Sublime Text 中为自定义语法启用自动注释,.tmPreferences
文件用于指定语法的注释标记.
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.
要编辑 R 的注释标记:
To edit the comment markers for R:
- 安装PackageResourceViewer
- 打开命令面板
- 输入
PRV:O
- 选择
PackageResourceViewer:打开资源
- 选择
R
- 选择
Comments.tmPreferences
- 编辑
TM_COMMENT_START
值/a> 到#'
根据需要 - 保存文件
- 在 R 文件上使用切换注释功能,并看到它现在使用
#'
而不是#
- Install PackageResourceViewer
- Open the command palette
- Type
PRV: O
- Select
PackageResourceViewer: Open Resource
- Select
R
- Select
Comments.tmPreferences
- Edit the
TM_COMMENT_START
value to#'
as desired - Save the file
- Use the toggle comment functionality on an R file and see that it now uses
#'
instead of#
这篇关于在 Sublime Text 3 中,如何更改注释字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!