on master help sign in
commands: add W and B (extend selection by word).
commita702af0aeb4562cbcdf8e2bc4008b8ce95da9a56 authorBlaž Hrastnik <blaz@mxxn.io> dateFri 22 Jan 2021, 16:31 (6 years ago) parentd9fb60e
2 files changed+21
helix-term/src/commands.rs+18 helix-term/src/keymap.rs+3
helix-term/src/commands.rs+18
@@ -161,6 +161,24 @@ pub fn move_file_end(cx: &mut Context) {
161161 cx.doc().mode = Mode::Normal;
162162}
163163
164+pub fn extend_next_word_start(cx: &mut Context) {
165+ let count = cx.count;
166+ let selection = cx
167+ .doc()
168+ .state
169+ .extend_selection(Direction::Forward, Granularity::Word, count);
170+ cx.doc().set_selection(selection);
171+}
172+
173+pub fn extend_prev_word_start(cx: &mut Context) {
174+ let count = cx.count;
175+ let selection = cx
176+ .doc()
177+ .state
178+ .extend_selection(Direction::Backward, Granularity::Word, count);
179+ cx.doc().set_selection(selection);
180+}
181+
164182pub fn check_cursor_in_view(view: &View) -> bool {
165183 let doc = &view.doc;
166184 let cursor = doc.selection().cursor();
helix-term/src/keymap.rs+3
@@ -146,8 +146,11 @@ pub fn default() -> Keymaps {
146146 vec![shift!('K')] => commands::extend_line_up,
147147 vec![shift!('L')] => commands::extend_char_right,
148148 vec![key!('w')] => commands::move_next_word_start,
149+ vec![shift!('W')] => commands::extend_next_word_start,
149150 vec![key!('b')] => commands::move_prev_word_start,
151+ vec![shift!('B')] => commands::extend_prev_word_start,
150152 vec![key!('e')] => commands::move_next_word_end,
153+ // TODO: E
151154 vec![key!('g')] => commands::goto_mode,
152155 vec![key!('i')] => commands::insert_mode,
153156 vec![shift!('I')] => commands::prepend_to_line,