diff options
author | Blaž Hrastnik | 2021-01-22 07:31:49 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-01-22 07:31:49 +0000 |
commit | a702af0aeb4562cbcdf8e2bc4008b8ce95da9a56 (patch) | |
tree | 4d5dad104ee816d1f52a0776d14618c70422235f /helix-term | |
parent | d9fb60e3015d8cbd08882c5fb49b2f2a58435b1a (diff) |
commands: add W and B (extend selection by word).
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/commands.rs | 18 | ||||
-rw-r--r-- | helix-term/src/keymap.rs | 3 |
2 files changed, 21 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 8e39972c..4a461239 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -161,6 +161,24 @@ pub fn move_file_end(cx: &mut Context) { cx.doc().mode = Mode::Normal; } +pub fn extend_next_word_start(cx: &mut Context) { + let count = cx.count; + let selection = cx + .doc() + .state + .extend_selection(Direction::Forward, Granularity::Word, count); + cx.doc().set_selection(selection); +} + +pub fn extend_prev_word_start(cx: &mut Context) { + let count = cx.count; + let selection = cx + .doc() + .state + .extend_selection(Direction::Backward, Granularity::Word, count); + cx.doc().set_selection(selection); +} + pub fn check_cursor_in_view(view: &View) -> bool { let doc = &view.doc; let cursor = doc.selection().cursor(); diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index 132c81d0..440a3efb 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -146,8 +146,11 @@ pub fn default() -> Keymaps { vec![shift!('K')] => commands::extend_line_up, vec![shift!('L')] => commands::extend_char_right, vec![key!('w')] => commands::move_next_word_start, + vec![shift!('W')] => commands::extend_next_word_start, vec![key!('b')] => commands::move_prev_word_start, + vec![shift!('B')] => commands::extend_prev_word_start, vec![key!('e')] => commands::move_next_word_end, + // TODO: E vec![key!('g')] => commands::goto_mode, vec![key!('i')] => commands::insert_mode, vec![shift!('I')] => commands::prepend_to_line, |