我发现了这old thread条(一年前的),这解释了为什么R不支持多行注释(比如PHP的/*comment*/).
我想知道这一问题在过go 一年里是否得到了解决,或者是否还有其他 Select ?(例如,在使用npptor的notepad++中,可以标记一组行,然后按ctrl+q将它们全部标记为注释,其他IDE有类似的解决方案吗?)
我发现了这old thread条(一年前的),这解释了为什么R不支持多行注释(比如PHP的/*comment*/).
我想知道这一问题在过go 一年里是否得到了解决,或者是否还有其他 Select ?(例如,在使用npptor的notepad++中,可以标记一组行,然后按ctrl+q将它们全部标记为注释,其他IDE有类似的解决方案吗?)
You can, if you want, use standalone strings for multi-line comments — I've always thought that prettier than if (FALSE) { }
blocks. The string will get evaluated and then discarded, so as long as it's not the last line in a function nothing will happen.
"This function takes a value x, and does things and returns things that
take several lines to explain"
doEverythingOften <- function(x) {
# Non! Comment it out! We'll just do it once for now.
"if (x %in% 1:9) {
doTenEverythings()
}"
doEverythingOnce()
...
return(list(
everythingDone = TRUE,
howOftenDone = 1
))
}
主要的限制是,当你在 comments 内容时,你必须注意你的引号:如果你有一种在里面,你必须用另一种来 comments ;如果你在那个块里有类似"带后记的字符串"的东西,那么这个方法不可能是个好主意.但还有if (FALSE)
街区.
另一个限制是,这两种方法都有一个限制,即只能在表达式在语法上有效的地方使用这样的块,例如,不能注释列表中的部分内容.
关于在哪个IDE中做什么:我是Vim用户,我发现
最后,在R提示符下(至少在Linux下),有可爱的Alt-Shift-#来 comments 当前行.如果你在做一条线,然后意识到你需要先准备一步,那么很高兴能"暂停"一条线.