47

I first encountered on GitHub the "suggestion" code block, identified by

```suggestion
change
```

This offers to replace the line immediately before with what is inside the fence. But what about if I want to replace multiple lines?

I'd like to think this is possible, but I cannot find documentation of this feature anywhere. I have at least learned that the key terms to use are fenced code block and info string but the best I can come up with is that the info string (other than the first token) is unspecified.

Is this capability documented anywhere? It is emminently useful in code reviews.

Edit: This is a markdown question not a GitHub question

So far, it appears to be a GitHub-unique feature. That may be the answer, but telling me how to use the GitHub GUI is not addressing the question.

A.L
  • 10,259
  • 10
  • 67
  • 98
jwm
  • 1,504
  • 1
  • 14
  • 29
  • I'm having the same problem on Azure Devops, so it's not Github Exclusive. – Gloweye Nov 02 '22 at 13:03
  • It was never GitHub exclusive; my question arose from using Bitbucket (Atlassian). What I've learned is that, while fenced code blocks are a feature, the use of them as a multi-line suggestion does appear to be a GitHub-unique feature. – jwm Nov 02 '22 at 19:04

3 Answers3

79

To add a comment on multiple lines, click and drag to select the range of lines, then click the blue comment icon.

enter image description here

Kuncheria
  • 1,182
  • 9
  • 16
  • 11
    Thanks for the video. I was selecting the multiple lines but clicking the + on the first line which doesn't work, you need to select the + on the last line. – Pankaj Dec 13 '21 at 18:16
3

Multi-line Github change request can be achieved by combining multi-line commenting and change request feature.

Step 1. Select multi-line commenting feature for lines that needs to be changed- How to do it

Step 2. then press <cmd+g>

Tada!!! Add your change request.

paragxviii
  • 220
  • 1
  • 9
  • 2
    I’m sorry if it wasn’t clear, but this is a Markdown question more than a GitHub question. At work we use Bitbucket, which also has limited support for the `suggestion` fenced code block. I have come to accept that Markdown varies widely, so the GitHub implementation may well be a unique feature. – jwm Nov 11 '20 at 15:44
1

Github released multi-line code suggestions on February 26, 2020:

https://github.blog/changelog/2020-02-26-multi-line-code-suggestions-beta/

To select a multi-line code block, you can either:

  • click and hold to the right of a line number, drag and then release the mouse when you’ve reached the last line of the desired selection; or
  • click on a line number, hold Shift, click on a second line number and click the "+" button to the right of the second line number.

Once you've selected the code block, click the diff icon and edit the text within the suggestion block.

Community
  • 1
  • 1
Pat Myron
  • 4,437
  • 2
  • 20
  • 39