Home Explore Blog CI



nushell

2nd chunk of `book/line_editor.md`
d6d7d995fd2a5f0b94b475a8873564f05e205fa22ac56c040000000100000fca
(and more) of modal editing.
:::

## Default Keybindings

Each edit mode comes with common keybindings for Vi and Emacs text editing.

### Emacs and Vi-insert Keybindings

These keybinding events apply to both Emacs and Vi-insert mode:

| Key                                        | Event                               |
| ------------------------------------------ | ----------------------------------- |
| <kbd>Shift</kbd>+<kbd>Enter</kbd>          | Insert newline                      |
| <kbd>Alt</kbd>+<kbd>Enter</kbd>            | Insert newline                      |
| <kbd>Backspace</kbd>                       | Backspace                           |
| <kbd>End</kbd>                             | Move to end of line                 |
| <kbd>End</kbd>                             | Complete history hint               |
| <kbd>Home</kbd>                            | Move to line start                  |
| <kbd>Ctrl</kbd>+<kbd>C</kbd>               | Cancel current line                 |
| <kbd>Ctrl</kbd>+<kbd>L</kbd>               | Clear screen                        |
| <kbd>Ctrl</kbd>+<kbd>R</kbd>               | Search history                      |
| <kbd>Ctrl</kbd>+<kbd>→</kbd> (Right Arrow) | Complete history word               |
| <kbd>Ctrl</kbd>+<kbd>→</kbd> (Right Arrow) | Move word right                     |
| <kbd>Ctrl</kbd>+<kbd>←</kbd> (Left Arrow)  | Move word left                      |
| <kbd>↑</kbd> (Up Arrow)                    | Move up                             |
| <kbd>↓</kbd> (Down Arrow)                  | Move down                           |
| <kbd>←</kbd> (Left Arrow)                  | Move left                           |
| <kbd>→</kbd> (Right Arrow)                 | Move right                          |
| <kbd>Ctrl</kbd>+<kbd>P</kbd>               | Move up                             |
| <kbd>Ctrl</kbd>+<kbd>N</kbd>               | Move down                           |
| <kbd>Ctrl</kbd>+<kbd>B</kbd>               | Move left                           |
| <kbd>Ctrl</kbd>+<kbd>F</kbd>               | Move right                          |
| <kbd>→</kbd> (Right Arrow)                 | History-hint complete               |
| <kbd>Ctrl</kbd>+<kbd>F</kbd>               | History-hint complete               |
| <kbd>Alt</kbd>+<kbd>F</kbd>                | History-hint complete one word      |
| <kbd>Alt</kbd>+<kbd>←</kbd> (Left Arrow)   | History-hint complete one word less |

### Vi-insert Keybindings

These keybinding events apply only to Vi-insert mode:

| Key            | Event                    |
| -------------- | ------------------------ |
| <kbd>Esc</kbd> | Switch to Vi-normal mode |

### Vi-normal Keybindings

These keybinding events apply only to Vi-normal mode:

| Key                                         | Event               |
| ------------------------------------------- | ------------------- |
| <kbd>Ctrl</kbd>+<kbd>C</kbd>                | Cancel current line |
| <kbd>Ctrl</kbd>+<kbd>L</kbd>                | Clear screen        |
| <kbd>↑</kbd> (Up Arrow)                     | Move up             |
| <kbd>↓</kbd> (Down Arrow)                   | Move down           |
| <kbd>←</kbd> (Left Arrow)                   | Move left           |
| <kbd>→</kbd> (Right Arrow)                  | Move right          |
| <kbd>Ctrl></kbd>+<kbd>→</kbd> (Right Arrow) | Move right one word |
| <kbd>Ctrl></kbd>+<kbd>←</kbd> (Left Arrow)  | Move left one word  |

### Vi-normal Motions

As with Vi, many motions and actions can be combined with an optional count in normal-mode. For example, <kbd>3</kbd><kbd>d</kbd><kbd>w</kbd> deletes the next three words.

| Key                                    | Motion                                        |
| -------------------------------------- | --------------------------------------------- |
| <kbd>w</kbd>                           | Move to beginning of next word                |
| <kbd>e</kbd>                           | Move to end of current or next word           |

Title: Reedline: Default Keybindings for Emacs, Vi-insert, and Vi-normal Modes
Summary
This section details the default keybindings for Reedline's editing modes: Emacs, Vi-insert, and Vi-normal. It outlines specific key combinations for various actions like inserting newlines, moving the cursor, clearing the screen, searching history, and switching between Vi modes. Additionally, it describes Vi-normal motions and how they can be combined with counts for actions like deleting multiple words.