How to do block comments in Gherkin?

dbruning picture dbruning · Aug 18, 2011 · Viewed 91.2k times · Source

In gherkin syntax (used by Cucumber and SpecFlow, I can comment out a line by prefixing it with '#'

Is there any way to block-comment multiple lines?

Answer

Tz_ picture Tz_ · Aug 19, 2011

It is not supported by Gherkin, so you have to prefix all lines with #.

If you use the SpecFlow Visual Studio extension (v1.9.2) you can simply select the lines and toggle them into comments and back. The default shortcuts are Ctrl+K,C to comment and Ctrl+K,U to uncomment.

You can also "workaround" this problem in Visual Studio using the multi-line editing feature. (See http://weblogs.asp.net/scottgu/archive/2010/04/26/box-selection-and-multi-line-editing-with-vs-2010.aspx). You just have to select the beginning of the lines with holding ALT and using the mouse. Using this feature you can type in all the selected lines at the same time. You can also remove all of them similarly, selecting all the # characters for deletion.