Skip to content

Commit d3ce6c3

Browse files
committed
Make initial editing mode configurable
ref: helix-editor#3366
1 parent 28bcf13 commit d3ce6c3

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

book/src/configuration.md

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Its settings will be merged with the configuration directory `config.toml` and t
5959
| `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative | `false` |
6060
| `undercurl` | Set to `true` to override automatic detection of terminal undercurl support in the event of a false negative | `false` |
6161
| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file | `[]` |
62+
| `initial-mode` | The initial mode for newly opened editors. | `"normal"` |
6263
| `bufferline` | Renders a line at the top of the editor displaying open buffers. Can be `always`, `never` or `multiple` (only shown if more than one buffer is in use) | `never` |
6364
| `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` |
6465
| `text-width` | Maximum line length. Used for the `:reflow` command and soft-wrapping if `soft-wrap.wrap-at-text-width` is set | `80` |

helix-view/src/editor.rs

+4
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ pub struct Config {
281281
pub bufferline: BufferLine,
282282
/// Vertical indent width guides.
283283
pub indent_guides: IndentGuidesConfig,
284+
/// The initial mode for newly opened editors. Defaults to `"normal"`.
285+
pub initial_mode: Mode,
284286
/// Whether to color modes with different colors. Defaults to `false`.
285287
pub color_modes: bool,
286288
pub soft_wrap: SoftWrap,
@@ -812,6 +814,7 @@ impl Default for Config {
812814
whitespace: WhitespaceConfig::default(),
813815
bufferline: BufferLine::default(),
814816
indent_guides: IndentGuidesConfig::default(),
817+
initial_mode: Mode::Normal,
815818
color_modes: false,
816819
soft_wrap: SoftWrap {
817820
enable: Some(false),
@@ -1363,6 +1366,7 @@ impl Editor {
13631366

13641367
/// Generate an id for a new document and register it.
13651368
fn new_document(&mut self, mut doc: Document) -> DocumentId {
1369+
self.mode = self.config().initial_mode;
13661370
let id = self.next_document_id;
13671371
// Safety: adding 1 from 1 is fine, probably impossible to reach usize max
13681372
self.next_document_id =

0 commit comments

Comments
 (0)