<!--
{
  "availability" : [
    "macOS: 10.12.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XcodeKit",
  "identifier" : "/documentation/XcodeKit/XCSourceTextBuffer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "XcodeKit"
    ],
    "preciseIdentifier" : "c:objc(cs)XCSourceTextBuffer"
  },
  "title" : "XCSourceTextBuffer"
}
-->

# XCSourceTextBuffer

A buffer you use to access and modify the text contents and text selections in a source editor.

```
class XCSourceTextBuffer
```

## Overview

Mutations to the buffer are tracked and committed when a command completes successfully and has not been canceled by the user.

## Topics

### Accessing Source Text

[`var completeBuffer: String`](/documentation/XcodeKit/XCSourceTextBuffer/completeBuffer)

The complete buffer’s string representation.

[`var contentUTI: String`](/documentation/XcodeKit/XCSourceTextBuffer/contentUTI)

The Uniform Type Identifier (UTI) of the content in the buffer.

### Editing Source Text

[`var lines: NSMutableArray`](/documentation/XcodeKit/XCSourceTextBuffer/lines)

The lines of text in the buffer, including line endings.

[`var selections: NSMutableArray`](/documentation/XcodeKit/XCSourceTextBuffer/selections)

The text selections in the buffer.

### Configuring Source Editor Indentation

[`var indentationWidth: Int`](/documentation/XcodeKit/XCSourceTextBuffer/indentationWidth)

The number of space characters used for indentation of the text in the buffer.

[`var usesTabsForIndentation: Bool`](/documentation/XcodeKit/XCSourceTextBuffer/usesTabsForIndentation)

A Boolean value that indicates whether tabs are used for indentation.

[`var tabWidth: Int`](/documentation/XcodeKit/XCSourceTextBuffer/tabWidth)

The number of space characters represented by a tab character in the buffer.

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)