oracle 是否可以注释掉包含注释的代码块?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30375611/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to comment out blocks of code that contain comments?
提问by Mladen Or?oli?
Say I have code like this
说我有这样的代码
some_line_of_code
some_line_of_code
/* some comment about code */
some_line_of_code
some_line_of_code
and i would like to comment out a whole block like this
我想像这样注释掉整个块
/*
some_line_of_code
some_line_of_code
/* some comment about code */
some_line_of_code
some_line_of_code
*/
As you can see even SO code parser will not consider last 2 lines of code comments. Is it possible to comment out blocks of code that contain comments?
如您所见,即使是 SO 代码解析器也不会考虑最后 2 行代码注释。是否可以注释掉包含注释的代码块?
edit : To clarify, I need this to be able to comment out large sections of code to check if a function I changed can compile in a package that otherwise can't be compiled until all changes have been done.
编辑:为了澄清,我需要它能够注释掉大部分代码以检查我更改的函数是否可以在包中编译,否则在所有更改完成之前无法编译。
回答by Tony L.
In SQL Developer, I highlight all lines of PL/SQL that I want commented and use Ctrl+ /.
在 SQL Developer 中,我突出显示了我想要注释并使用Ctrl+ 的所有 PL/SQL 行/。
Obviously, you would like a way to comment and uncomment multiple lines quickly. This will put --
in front of each line you have highlighted. Do the same command to uncomment.
显然,您想要一种快速注释和取消注释多行的方法。这将放在--
您突出显示的每一行之前。执行相同的命令取消注释。
回答by ibre5041
As was stated by @Acroneos, there is no way. This is common behaviour of most programming languages. Comments as well as oher tokens are recognized by lexers. And lexers work with context-free grammars. i.e. lexes usually can recognize only reqular expressions.
正如@Acroneos 所说,没有办法。这是大多数编程语言的常见行为。词法分析器识别注释以及其他标记。词法分析器使用上下文无关文法。即词法通常只能识别正则表达式。
You can still use C/C++ approach (#if 0
/#endif
). See Conditional compilation. But it does not look "so nice".
您仍然可以使用 C/C++ 方法 ( #if 0
/ #endif
)。请参阅条件编译。但它看起来并不“那么好”。
begin
something1;
$if false $then
something2;
$endif;
endl;
回答by Galileo
you can assign a function key through Tools > Preferences > Key Configuration (Edit / Selection / Comment Lines).
您可以通过工具 > 首选项 > 键配置(编辑/选择/注释行)分配功能键。
回答by Xakiru
you can use --
你可以用——
so this code :
所以这个代码:
some_line_of_code
some_line_of_code
-- some comment about code
some_line_of_code
some_line_of_code
some_line_of_code
some_line_of_code
-- some comment about code
some_line_of_code
some_line_of_code
will be :
将会 :
--some_line_of_code
--some_line_of_code
---- some comment about code
--some_line_of_code
--some_line_of_code
--some_line_of_code
--some_line_of_code
---- some comment about code
--some_line_of_code
--some_line_of_code
回答by Acroneos
No, because everything between first delimiter until the next last delimiter will be recognized as comment (=not processed by compiler). Thats how multiline-comments work: If first delimiter (/ * ) is recognized, compiler will ignore anything until the very next last delimiter ( * /) is recognized. Now as you know this, you should be able to understand, why your second / * will never be recognized as a comment-delimiter by the compiler.
不,因为第一个分隔符到下一个最后一个分隔符之间的所有内容都将被识别为注释(=编译器未处理)。这就是多行注释的工作原理:如果识别出第一个分隔符 (/*),编译器将忽略任何内容,直到识别出下一个最后一个分隔符 (*/)。现在您知道了这一点,您应该能够理解,为什么您的第二个 /* 永远不会被编译器识别为注释分隔符。
However, you can mark comments with special characters or concatenations within the multiline-comment-sector to line out comments into different sections.
但是,您可以在 multiline-comment-sector 中使用特殊字符或串联标记注释,以将注释划入不同的部分。
回答by MagicWorld
Shortcut to comment a line: Command + Option + / (in Mac)
注释行的快捷方式:Command + Option + /(在 Mac 中)