<!--
{
  "availability" : [
    "macOS: 15.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextView/highlight(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextView(im)highlight:"
  },
  "title" : "highlight(_:)"
}
-->

# highlight(_:)

An action for toggling `NSTextHighlightStyleAttributeName` in the receiver’s selected range.
The sender should be a menu item with a `representedObject` of type (`NSTextHighlightColorScheme`).

```
@IBAction func highlight(_ sender: Any?)
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)