How do you do block comments in YAML?

前端 未结 11 1505
误落风尘
误落风尘 2020-12-04 04:26

How do I comment a block of lines in YAML?

相关标签:
11条回答
  • 2020-12-04 05:14

    In Vim you can do one of the following:

    • Comment all lines: :%s/^/#
    • Comment lines 10 - 15: :10,15s/^/#
    • Comment line 10 to current line: :10,.s/^/#
    • Comment line 10 to end: :10,$s/^/#

    or using visual block:

    1. Select a multiple-line column after entering visual block via Ctrl+v.
    2. Press r followed by # to comment out the multiple-line block replacing the selection, or Shift+i#Esc to insert comment characters before the selection.
    0 讨论(0)
  • 2020-12-04 05:14

    For Visual Studio Code (VSCode) users, the shortcut to comment out multiple lines is to highlight the lines you want to comment and then press:

    ctrl + /

    Pressing ctrl + / again can also be used to toggle comments off for one or more selected lines.

    0 讨论(0)
  • 2020-12-04 05:14

    In Azure Devops browser(pipeline yaml editor),

    Ctrl + K + C Comment Block

    Ctrl + K + U Uncomment Block

    There also a 'Toggle Block Comment' option but this did not work for me.

    There are other 'wierd' ways too: right click to see 'Command Palette' or F1

    Then choose a cursor option.

    Now it is just a matter of #

    or even smarter [Ctrl + k] + [Ctrl + c]

    0 讨论(0)
  • 2020-12-04 05:20

    The spec only describes one way of marking comments:

    An explicit comment is marked by a “#” indicator.

    That's all. There are no block comments.

    0 讨论(0)
  • 2020-12-04 05:20

    If you are using Eclipse with the yedit plugin (an editor for .yaml files), you can comment-out multiple lines by:

    1. selecting lines to be commented, and then
    2. Ctrl + Shift + C

    And to un-comment, follow the same steps.

    0 讨论(0)
提交回复
热议问题