Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

iced_richedit

iced_richedit is a native rich text editor widget for iced.

The library is actively under development and is not ready for production use.

Reading this guide

Getting started

Requirements

Use a recent stable Rust toolchain. Run the commands below from the repository root.

Run the example

Choose either wgpu or tiny-skia to run the example.

wgpu

cargo run --locked --example basic --features example-basic-wgpu

tiny-skia

cargo run --locked --example basic --features example-basic-tiny-skia

Behavior

In the examples below, | marks the cursor.

Selections across blocks

A selection can start in one block and end in another. Select in either direction, then type or paste to replace the text, or press Backspace or Delete to remove it. You can also use an input method to type over the selection.

The text on either side usually joins up. If joining the two pieces would strip formatting from text you didn’t select, they stay in separate blocks.

Lists

Use bullet or numbered lists to organize paragraphs. Each item can contain formatted text and line breaks. Nested lists and items containing multiple paragraphs are not supported yet.

Create or change a list

Select paragraphs and choose Bullet list or Ordered list. Each paragraph becomes an item. With no selection, only the current paragraph is used.

Inside a list, either control changes the whole list, even if only a few items are selected. Choosing the same type again leaves the list as it is. Use Remove list to remove its formatting.

New numbered lists start at 1. You can change the starting number for the whole list. Numbers update automatically when you add or remove items.

Remove list formatting

Choose Remove list to turn the current item into a normal paragraph. To remove several items from a list, select them first. Their text and formatting are kept.

The items before and after the removed section remain lists. The later numbered list keeps its original numbers:

Before:                  Remove list from B:

7. A                     7. A
8. B
9. C                     B

                         9. C

Enter and Shift+Enter

Enter starts a new item. If the cursor is in the middle of an item, the text after it moves to the new item:

Before:                  After Enter:

1. Hello |world           1. Hello
                         2. |world

At the start of an item, Enter leaves an empty item above it. At the end, it adds an empty item below it.

Enter in an empty item turns that item into a normal paragraph, letting you leave the list. Any items below it remain a separate list with their original numbers.

Shift+Enter adds a line break within the current item, without a new bullet or number:

Before:                  After Shift+Enter:

1. Hello |world           1. Hello
                            |world

Backspace and Delete

When text is selected, Backspace and Delete remove the selection. Otherwise, their behavior depends on the cursor position:

Cursor positionKeyResult
Start of the first itemBackspaceTurn that item into a normal paragraph
Start of any later itemBackspaceJoin it to the previous item
End of an item with another item belowDeleteJoin the next item to it
End of the last item, followed by a normal paragraphDeleteJoin that paragraph to the last item
Start of a normal paragraph immediately after a listBackspaceJoin the paragraph to the last item

Joining items does not insert a space or line break:

Before:                  After Backspace:

1. Hello                 1. Hello|world
2. |world

Word deletion follows the same rules at these boundaries. Inside an item, it deletes words normally.

Between separate lists

Separate lists do not merge automatically.

Pressing Delete at the end of the first list does nothing. Pressing Backspace at the start of the second list turns its first item into a normal paragraph.

If an empty paragraph separates the lists, Backspace at its start removes that paragraph. The lists still remain separate.

Delete at the end of a list also does not pull in a following heading, code block, or quote.

Select and replace text

You can select text across items in the same list, then delete it or replace it by typing or pasting. The text on either side joins together.

For example, selecting from after a to before d, then typing X:

Before:                  After:

1. ab                    1. aX|d
2. cd

Deleting all item content leaves one empty item. Press Enter to turn it into a normal paragraph.

You can also select from a paragraph into a list, or from one list into another. In the example below, select from just after ab to just before gh, then type X. The two pieces of text join in item 3. Item 21 still belongs to the second list, so it keeps its number:

Before:                  After:

 3. abcd                  3. abX|gh

20. efgh                 21. tail
21. tail

Paste

Pasting multiple lines creates list items. The text after the cursor moves to the end of the last pasted line:

Before:                  Paste:         After:

1. A|B                   x              1. Ax
                         y              2. y|B

Blank lines are kept as empty items. Pasting a newline into an empty item creates another item rather than leaving the list.

Input methods

If you use an input method, you can start typing over a selection even when it extends beyond the list. As you type in a list item, each new line appears as another item. Cancel and the original text comes back. If you confirm instead, a single Undo brings it back.

Numbers, selection, and undo

Click a bullet or number to place the cursor at the start of its item. Bullets and numbers are not selected or copied with the text. When text wraps, each line aligns with the text above it.

Use Up and Down to move between lines. Hold Shift to extend the selection.

A multiline paste is one edit: Undo removes all the pasted lines together, and Redo puts them back.

Numbered lists accept starting numbers from 1 to 4,294,967,295. The last item’s number must also fit in that range. An edit that would exceed it leaves the document unchanged.

Code blocks

Code blocks hold plain text and line breaks. Spaces and blank lines are preserved. Unlike ordinary paragraphs, they do not support bold, italic, links, or other inline formatting.

Create a code block

Choose Code Block to turn the current paragraph or heading into a code block. If several blocks are selected, each becomes a separate code block. They are not combined.

Converting text to a code block removes its inline formatting but keeps the text and line breaks. Choose Body or a heading to convert it back. Its lines stay in one paragraph or heading rather than becoming separate paragraphs.

Code blocks cannot be created inside list items yet.

Enter and Shift+Enter

Both Enter and Shift+Enter insert a new line in the same code block. They do not create another block or leave the code block, even on an empty line.

Before:                  After Enter:

let a = 1;|              let a = 1;
                         |

With text selected inside a code block, Enter replaces the selection with a line break.

Backspace and Delete

Inside a code block, Backspace and Delete remove text normally. Deleting a line break joins the two lines without leaving the block.

At the start or end of a block, the result depends on its neighbor:

Cursor positionKeyResult
Start of a code block at the beginning of the documentBackspaceTurn it into a normal paragraph
Start of an empty code blockBackspaceTurn it into a normal paragraph without joining the previous block
Start of a code block containing text, after a paragraph, heading, or code blockBackspaceJoin it to the previous block
End of a code block, before a paragraph, heading, or code blockDeleteJoin the following block to it
Start of a normal paragraph immediately after a code blockBackspaceJoin the paragraph to the code block

Joining blocks keeps the type of the first block and does not insert a space or line break. Text joined into a code block loses its inline formatting. Code joined into a paragraph or heading keeps its line breaks.

For example, pressing Backspace at the start of code after a normal paragraph:

Before:                  After:

Hello                    Hello|world

|world

The result is a normal paragraph. With Delete at the end of code followed by a normal paragraph, the result stays a code block.

If a heading follows a code block, Backspace at the heading’s start first turns the heading into a normal paragraph. A second Backspace joins it to the code block.

Word deletion follows the same rules at these boundaries. If text is selected, deletion removes the selection instead.

Paste and input methods

Pasting several lines keeps them in the same code block. Blank lines and a final line break are preserved. Line endings are converted to the editor’s standard newline format.

If you use an input method, you can type several lines of code before confirming. They stay in the same code block as plain text.

You can also select from a paragraph or list item into code. If you delete that selection and the rest of the code joins the paragraph or list item, it keeps its line breaks.

Undo and redo

Use Undo to restore text, formatting, or block types after an edit. Redo reapplies the change. Converting text to a code block can be undone, including the formatting removed during conversion.