# Editing Text

*Lx* keeps common editing actions close at hand.

## Save and undo

| Shortcut | Action |
| --- | --- |
| Ctrl+S | Save |
| Ctrl+Shift+S | Save As |
| Ctrl+Z | Undo |
| Ctrl+Shift+Z | Redo |

## Select text

Drag with the mouse, or hold **Shift** while moving the cursor.

Useful selection shortcuts include:

| Shortcut | Action |
| --- | --- |
| Ctrl+A | Select everything |
| Ctrl+L | Select whole lines |
| Ctrl+Shift+Left | Select to the previous word |
| Ctrl+Shift+Right | Select to the next word |
| Shift+Home | Select to the start of the line |
| Shift+End | Select to the end of the line |

## Work with lines

| Shortcut | Action |
| --- | --- |
| Ctrl+Y | Delete the selected lines |
| Ctrl+Shift+D | Duplicate the selected lines |
| Ctrl+J | Join lines |
| Tab | Indent |
| Shift+Tab | Unindent |
| Ctrl+/ | Add or remove line comments |

Most line actions also work when you have only a cursor and no selection.

## Indent text

Press **Tab** to indent and **Shift+Tab** to unindent. *Lx* can insert spaces or literal tab characters, and it detects the likely choice separately for each document.

The status bar shows the active setting as `Spaces: N` or `Tabs: N`. An added `*` means the size is automatic.

- Click the status item to cycle through automatic detection and the default sizes 2, 4, and 8.
- Middle-click it to re-scan the document and return both the type and size to automatic detection.
- Hold **Alt** while clicking to switch between spaces and tabs without rewriting the file.

Changing what **Tab** inserts is not the same as converting existing indentation. See [Indentation](indentation.md) for automatic detection, status controls, conversion commands, and settings.

## Use more than one cursor

- Press **Ctrl+Alt+Up** or **Ctrl+Alt+Down** to add a cursor on the line above or below.
- Press **Alt+D** to select the next occurrence of the current word or selection.
- Press **Shift+Alt+I** to place a cursor at the end of every selected line.
- Press **Escape** to remove extra cursors.

Typing and editing then apply at every cursor.

## Wrap long lines

Press **Alt+Z** to turn word wrapping on or off. You can also click **Wrap** or **No Wrap** in the status bar.

Wrapping changes how a long line fits on screen. It does not add line breaks to the file.

## Format marked-up text

*Lx* can add or remove markers for bold, italic, underline, and other supported formats. It can also surround selected text as you type.

See [Formatting and Surrounding Text](format_shortcuts.md) and [Auto Surround](auto_surround.md).
