You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nushell's lineeditor [Reedline](https://github.com/nushell/reedline) is a
4
-
cross-platform line reader designed to be modular and flexible. The engine is
5
-
in charge of controlling the command history, validations, completions, hints
6
-
and screen paint.
3
+
Nushell's line-editor [Reedline](https://github.com/nushell/reedline) is
4
+
cross-platform and designed to be modular and flexible. The line-editor is
5
+
in charge of controlling the command history, validations, completions, hints,
6
+
screen paint, and more.
7
7
8
-
## Configuration
8
+
[[toc]]
9
9
10
-
### Editing Mode
10
+
##Multi-line Editing
11
11
12
-
Reedline allows you to edit text using two modes: vi and emacs. If not
13
-
specified, the default edit mode is emacs mode. In order to select your
14
-
favorite you need to modify your config file and write down your preferred
15
-
mode.
12
+
Reedline allows Nushell commandlines to extend across multiple lines. This can be accomplished using several methods:
16
13
17
-
For example:
14
+
1. Pressing <kbd>Enter</kbd> when a bracketed expression is open.
15
+
16
+
For example:
17
+
18
+
```nu
19
+
def my-command [] {
20
+
```
21
+
22
+
Pressing <kbd>Enter </kbd> after the open-bracket will insert a newline. This will also occur with opening (and valid) `(` and `[` expressions.
23
+
24
+
This is commonly used to create blocks and closures (as above), but also list, record, and table literals:
25
+
26
+
```nu
27
+
let file = {
28
+
name: 'repos.sqlite'
29
+
hash: 'b939a3fa4ca011ca1aa3548420e78cee'
30
+
version: '1.4.2'
31
+
}
32
+
```
33
+
34
+
It can even be used to continue a single command across multiple lines:
35
+
36
+
```nu
37
+
(
38
+
ffmpeg
39
+
-i input.mp4
40
+
-vf "scale=1280:720,setsar=1:1"
41
+
-b:v 1500k
42
+
-preset veryfast
43
+
-crf 23
44
+
-c:a aac
45
+
-b:a 192k
46
+
-movflags +faststart
47
+
-y
48
+
output.mp4
49
+
)
50
+
```
51
+
52
+
2. Pressing <kbd>Enter</kbd> at the end of a line with a trailing pipe-symbol (`|`).
53
+
54
+
```nu
55
+
ls |
56
+
where name =~ '^[0-9]' | # filenames starting with a digit
57
+
get name | # get the filenames
58
+
mv ...$in ./backups/ # and move to backups folder
59
+
```
60
+
61
+
3. Manually insert a newline using <kbd>Alt</kbd>+<kbd>Enter</kbd> or <kbd>Shift</kbd>+<kbd>Enter</kbd>.
62
+
63
+
This can be used to create a somewhat more readable version of the previous commandline:
64
+
65
+
```nu
66
+
ls
67
+
| where name =~ '^[0-9]' # filenames starting with a digit
68
+
| get name # get the filenames
69
+
| mv ...$in ./backups/ # and move to backups folder
70
+
```
71
+
72
+
::: tip
73
+
It's possible that one or both of these keybindings may be intercepted by the terminal application or window-manager. For instance, Windows Terminal (and most other terminal applications on Windows) assign <kbd>Alt</kbd>+<kbd>Enter</kbd> to expand the terminal to full-screen. If neither of the above keybindings work in your terminal, you can assign a different keybinding to:
74
+
75
+
```nu
76
+
event: { edit: insertnewline }
77
+
```
78
+
79
+
See [Keybindings](#keybindings) below for more details.
80
+
81
+
:::
82
+
83
+
4. Pressing <kbd>Ctrl</kbd>+<kbd>O</kbd> opens the current commandline in your editor. Saving the resulting file and exiting the editor will update the commandline with the results.
84
+
85
+
## Setting the Editing Mode
86
+
87
+
Reedline allows you to edit text using two modes — Vi and Emacs. If not
88
+
specified, the default mode is Emacs. To change the mode, use the
89
+
`edit_mode` setting.
18
90
19
91
```nu
20
-
$env.config = {
21
-
...
22
-
edit_mode: emacs
23
-
...
24
-
}
92
+
$env.config.edit_mode = 'vi'
25
93
```
26
94
27
-
#### Default Keybindings
28
-
29
-
Each edit mode comes with the usual keybinding for vi and emacs text editing.
30
-
31
-
Emacs and Vi Insert keybindings
32
-
33
-
| Key | Event |
34
-
| ----------- | --------------------- |
35
-
| Esc | Esc |
36
-
| Backspace | Backspace |
37
-
| End | Move to end of line |
38
-
| End | Complete history hint |
39
-
| Home | Move to line start |
40
-
| Ctr + c | Cancel current line |
41
-
| Ctr + l | Clear screen |
42
-
| Ctr + r | Search history |
43
-
| Ctr + Right | Complete history word |
44
-
| Ctr + Right | Move word right |
45
-
| Ctr + Left | Move word left |
46
-
| Up | Move menu up |
47
-
| Up | Move up |
48
-
| Down | Move menu down |
49
-
| Down | Move down |
50
-
| Left | Move menu left |
51
-
| Left | Move left |
52
-
| Right | History hint complete |
53
-
| Right | Move menu right |
54
-
| Right | Move right |
55
-
| Ctr + b | Move menu left |
56
-
| Ctr + b | Move left |
57
-
| Ctr + f | History hint complete |
58
-
| Ctr + f | Move menu right |
59
-
| Ctr + f | Move right |
60
-
| Ctr + p | Move menu up |
61
-
| Ctr + p | Move up |
62
-
| Ctr + n | Move menu down |
63
-
| Ctr + n | Move down |
64
-
65
-
Vi Normal keybindings
66
-
67
-
| Key | Event |
68
-
| ------- | ------------------- |
69
-
| Ctr + c | Cancel current line |
70
-
| Ctr + l | Clear screen |
71
-
| Up | Move menu up |
72
-
| Up | Move up |
73
-
| Down | Move menu down |
74
-
| Down | Move down |
75
-
| Left | Move menu left |
76
-
| Left | Move left |
77
-
| Right | Move menu right |
78
-
| Right | Move right |
79
-
80
-
Besides the previous keybindings, while in Vi normal mode you can use the classic
81
-
vi mode of executing actions by selecting a motion or an action. The available
82
-
options for the combinations are:
83
-
84
-
Vi Normal motions
85
-
86
-
| Key | motion |
87
-
| --- | ----------------- |
88
-
| w | Word |
89
-
| 0 | Line start |
90
-
| $ | Line end |
91
-
| f | Right until char |
92
-
| t | Right before char |
93
-
| F | Left until char |
94
-
| T | Left before char |
95
-
96
-
Vi Normal actions
97
-
98
-
| Key | action |
99
-
| --- | ------------------------------- |
100
-
| d | Delete |
101
-
| p | Paste after |
102
-
| P | Paste before |
103
-
| h | Move left |
104
-
| l | Move right |
105
-
| j | Move down |
106
-
| k | Move up |
107
-
| w | Move word right |
108
-
| b | Move word left |
109
-
| i | Enter Vi insert at current char |
110
-
| a | Enter Vi insert after char |
111
-
| 0 | Move to start of line |
112
-
| ^ | Move to start of line |
113
-
| $ | Move to end of line |
114
-
| u | Undo |
115
-
| c | Change |
116
-
| x | Delete char |
117
-
| s | History search |
118
-
| D | Delete to end |
119
-
| A | Append to end |
120
-
121
-
### Command History
95
+
This can be changed at the commandline or persisted in `config.nu`.
96
+
97
+
::: note
98
+
Vi is a "modal" editor with "normal" mode and an "insert" mode. We recommend
99
+
becoming familiar with these modes through the use of the Vim or Neovim editors
100
+
before using Vi mode in Nushell. Each has a built-in tutorial covering the basics
101
+
(and more) of modal editing.
102
+
:::
103
+
104
+
## Default Keybindings
105
+
106
+
Each edit mode comes with common keybindings for Vi and Emacs text editing.
| <kbd>Ctrl</kbd>+<kbd>C</kbd> | Cancel current line |
156
+
| <kbd>Ctrl</kbd>+<kbd>L</kbd> | Clear screen |
157
+
| <kbd>↑</kbd> (Up Arrow) | Move menu up |
158
+
| <kbd>↑</kbd> (Up Arrow) | Move up |
159
+
| <kbd>↓</kbd> (Down Arrow) | Move menu down |
160
+
| <kbd>↓</kbd> (Down Arrow) | Move down |
161
+
| <kbd>←</kbd> (Left Arrow) | Move menu left |
162
+
| <kbd>←</kbd> (Left Arrow) | Move left |
163
+
| <kbd>→</kbd> (Right Arrow) | Move menu right |
164
+
| <kbd>→</kbd> (Right Arrow) | Move right |
165
+
| <kbd>Ctrl></kbd>+<kbd>→</kbd> (Right Arrow) | Move right one word |
166
+
| <kbd>Ctrl></kbd>+<kbd>←</kbd> (Left Arrow) | Move left one word |
167
+
168
+
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.
You don't have to define the environment variables using Nushell
166
-
functions. You can use simple strings to define them.
167
-
:::
168
-
169
-
You can also customize the prompt indicator for the line editor by modifying
170
-
the next env variables.
227
+
## Customizing the Prompt
171
228
172
-
```nu
173
-
$env.PROMPT_INDICATOR = "〉"
174
-
$env.PROMPT_INDICATOR_VI_INSERT = ": "
175
-
$env.PROMPT_INDICATOR_VI_NORMAL = "〉"
176
-
$env.PROMPT_MULTILINE_INDICATOR = "::: "
177
-
```
178
-
179
-
::: tip
180
-
The prompt indicators are environment variables that represent the
181
-
state of the prompt
182
-
:::
229
+
The Reedline prompt is configured using a number of environment variables. See [Prompt Configuration](./configuration.md#prompt-configuration) for details.
0 commit comments