Selecting Line Ranges in Referenced Code Snippets records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.
ReviewedEvidence1 sourceSectionWriting & Style
Quick answer
When only part of a referenced source file is needed, use the supported Microsoft Learn line-range selection syntax to include the intended lines.
Key details
Core Issueline-range selection in snippet references
RegisterMicrosoft Learn technical documentation
Important caveats
Scope Boundary
Line ranges can become brittle when source files change; use them only when the contributor workflow makes that tradeoff acceptable and prefer more stable identifiers where appropriate.
Further guidance
Content
When only part of a referenced source file is needed, use the supported Microsoft Learn line-range selection syntax to include the intended lines.
Purpose
Keep technical documentation readable, reusable, and unambiguous for readers while following current Microsoft Learn contributor conventions.
Sources and evidence
Sources are shown with the role they play in this guide. Historical or style-sensitive claims are kept within the evidence boundary described above.
How to include code in docs — Microsoft Learn Contributor Guide↗ (opens in a new tab)Microsoft · Current Microsoft Learn contributor guidance on including code in documentation, including link/code styling, code-block quality checks, screenshots, validation, highlighting, scrollability, bad-code labeling, and in-repository snippet references.
Using Interactive Code Snippets in Documentation records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.
Using Triple-Colon Syntax for Referenced Code Snippets records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.
Automating Code Validation in Documentation records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.
Avoiding Horizontal Scrollbars in Code Blocks records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.
Displaying an Entire Referenced Code File records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.
Highlighting Key Lines in Code Blocks records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.
Referencing Named Code Snippets by ID records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.
Using Approved Language Tags in Fenced Code Blocks records a distinct Microsoft Learn authoring convention and keeps it scoped to that documentation environment rather than presenting it as a universal grammar rule.