({{, (RefLink[Snippet, paclet:ref/Snippet])[doc] 
gives a snippet of text from a document or other content object.}, {, (RefLink[Snippet, paclet:ref/Snippet])[doc,n]
gives about n lines from the beginning. }, {, (RefLink[Snippet, paclet:ref/Snippet])[doc,-n]
gives about n lines from the end.}, {, (RefLink[Snippet, paclet:ref/Snippet])[doc,(Subscript[n, 1]);;(Subscript[n, 2])]
gives a span from lines (Subscript[n, 1]) to (Subscript[n, 2])}, {, (RefLink[Snippet, paclet:ref/Snippet])[doc,(Subscript[n, 1]);;(Subscript[n, 2]);;(Subscript[n, 3])]
gives a span from lines (Subscript[n, 1]) to (Subscript[n, 2]) in steps of (Subscript[n, 3]).}, {, (RefLink[Snippet, paclet:ref/Snippet])[(RefLink[ContentObject, paclet:ref/ContentObject])[…],(RefLink[SearchResultObject, paclet:ref/SearchResultObject])[…]]
gives contextual snippets from a content object based on search results.}})

OpenersNotesSection(Spacer1)Details and Options

The default value for n is 1.

(RefLink[Snippet, paclet:ref/Snippet])[(RefLink[File, paclet:ref/File])[…]] and (RefLink[Snippet, paclet:ref/Snippet])[(RefLink[URL, paclet:ref/URL])[…]] give snippets from files and URLs, respectively.

OpenersPrimaryExamplesSection(Spacer1)Examples  (3)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Show a snippet of text contained in a (RefLink[ContentObject, paclet:ref/ContentObject]):

doc = ContentObject[ExampleData[{"Text", "AliceInWonderland"}]]

Snippet[doc]

Show only the first 3 lines:

Snippet[doc, 3]

Note that for (RefLink[ContentObject, paclet:ref/ContentObject]) there is an equivalent form:

doc["Snippet"]

OpenersExampleSection1(Spacer1)Scope  (2)

Show a snippet of text in a (RefLink[File, paclet:ref/File]):

Snippet[File["ExampleData/USConstitution.txt"]]

Without the (RefLink[File, paclet:ref/File]) wrapper, the path would be treated as data:

Snippet["ExampleData/USConstitution.txt"]

Show a three-line snippet of text from a (RefLink[URL, paclet:ref/URL]):

Snippet[URL["http://www.stephenwolfram.com"],3]

Without the (RefLink[URL, paclet:ref/URL]) wrapper, the string would be treated as data:

Snippet["http://www.stephenwolfram.com",3]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ContentObject, paclet:ref/ContentObject])  ▪  (RefLink[StringTake, paclet:ref/StringTake])  ▪  (RefLink[Thumbnail, paclet:ref/Thumbnail])  ▪  (RefLink[TextWords, paclet:ref/TextWords])  ▪  (RefLink[WordCloud, paclet:ref/WordCloud])  ▪  (RefLink[FilePrint, paclet:ref/FilePrint])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Text Analysis, paclet:guide/TextAnalysis])}, {▪(RefLinkPlain[Text Search, paclet:guide/TextSearch])}})}})