In YAML how can I comment a part of a line?
for example:
- name: "JAVA_OPTIONS"
value: "-Dconfig.dir.path=$(CONF_PATH) -Dpoint.dir.path=$(POINT_PATH)-
Xms256m -Xmx512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$(LOG_PATH)
-DMY_POD_NAME=$(MY_POD_NAME)"
How can I comment a string inside the value line?
Like "-Dpoint.dir.path=$(POINT_PATH)"
will be remarked but all the rest will take affect.
The shortcut key combination for commenting YAML blocks is Ctrl+Q. Select the block. Use “CTRL + /” on Linux and Windows and “CMD+/” for Mac operating system.
YAML does not support block or multi-line comments. In order to create a multi-line comment, we need to suffix each line with a # . # block comments.
Each line of comment starts with hashtag (#) symbol and blank space followed by description. Each line will end with new line break. Block comments are to comment the multiple lines . YAML has no support for block comments by default, You can use multiple inline comments
So unless there is some other commenting mechanism implemented by the program that interprets the YAML data (unlikely), the best thing to do is copy the whole line, comment one version out, and adjust the other: If you want to "roll-back" just move the comment token ( #) from the one line to the other.
YEdit is editor for yaml , to support Edit,Syntax highlight, Checking and content highligh with multiple colors. Please issue a shortcut command CTRL + Shift + C to comment the code To uncomment the code, Please select and issue the same shortcut command again to revert the comments. The other way is using menu or context menu option
The shortcut key combination for commenting YAML blocks is Ctrl+Q. If you are using Sublime Text editor, the steps for commenting the block are mentioned below − Select the block. Use “CTRL + /” on Linux and Windows and “CMD+/” for Mac operating system. Execute the block. Note that the same steps are applicable...
YAML only has comments that are in effect until the end of the line. So unless there is some other commenting mechanism implemented by the program that interprets the YAML data (unlikely), the best thing to do is copy the whole line, comment one version out, and adjust the other:
- name: "JAVA_OPTIONS"
# value: "-Dconfig.dir.path=$(CONF_PATH) -Dpoint.dir.path=$(POINT_PATH)-Xms256m -Xmx512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$(LOG_PATH) -DMY_POD_NAME=$(MY_POD_NAME)"
value: "-Dpoint.dir.path=$(POINT_PATH)-Xms256m -Xmx512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=$(LOG_PATH) -DMY_POD_NAME=$(MY_POD_NAME)"
If you want to "roll-back" just move the comment token (#
) from the one line to the other.
In the above I adjusted your input to be valid YAML. Your example is not valid because you cannot have both a sequence element and a key-value pair on the same level with the same parent (in this case the YAML document root).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With