Not trying to be smart about it, but if you use Sublime Text for your editor, the steps are:
I'd imagine that other editors have similar functionality too. Which one are you using? I'd be happy to do some digging.
In .gitlab-ci.yml file following works::
To comment out a block (multiline): Select the whole block section > Ctrl K C
To uncomment already commented out block (multiline): Select the whole block section > Ctrl K U
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.
An alternative approach:
If
then
Example:
Instead of
# This comment
# is too long
use
Description: >
This comment
is too long
or
Comment: >
This comment is also too long
and newlines survive from parsing!
More advantages:
Emacs has comment-dwim (Do What I Mean) - just select the block and do a:
M-;
It's a toggle - use it to comment AND uncomment blocks.
If you don't have yaml-mode installed you will need to tell Emacs to use the hash character (#).
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.
For Ruby Mine users on Windows:
Open file in editor Select the block and press Ctrl+forward slash, you will have selected block starting with #.
Now if you want to un-comment the commented block, press same key combination Ctrl+forward slash again
If you are using Eclipse with the yedit plugin (an editor for .yaml files), you can comment-out multiple lines by:
And to un-comment, follow the same steps.
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
Now it is just a matter of #
or even smarter [Ctrl + k] + [Ctrl + c]
In Vim you can do one of the following:
:%s/^/#
:10,15s/^/#
:10,.s/^/#
:10,$s/^/#
or using visual block:
Source: Stackoverflow.com