aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/commands.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-09-24 10:16:35 +0000
committerBlaž Hrastnik2020-09-24 10:16:35 +0000
commite0785aabe7618d5211f258a058bf08892ff04d06 (patch)
treed3ad697e560790c7ecdf5eb983a36f2502ab2636 /helix-view/src/commands.rs
parenteb639eb2e4610ed2b440c8d95217f125005288fd (diff)
Move-by-word commands: w, b, e.
Diffstat (limited to 'helix-view/src/commands.rs')
-rw-r--r--helix-view/src/commands.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/helix-view/src/commands.rs b/helix-view/src/commands.rs
index 560167c9..be3ea0b9 100644
--- a/helix-view/src/commands.rs
+++ b/helix-view/src/commands.rs
@@ -39,6 +39,41 @@ pub fn move_line_down(view: &mut View, count: usize) {
.move_selection(Direction::Forward, Granularity::Line, count);
}
+pub fn move_next_word_start(view: &mut View, count: usize) {
+ let pos = view.state.move_pos(
+ view.state.selection.cursor(),
+ Direction::Forward,
+ Granularity::Word,
+ count,
+ );
+
+ // TODO: use a transaction
+ view.state.selection = Selection::single(pos, pos);
+}
+
+pub fn move_prev_word_start(view: &mut View, count: usize) {
+ let pos = view.state.move_pos(
+ view.state.selection.cursor(),
+ Direction::Backward,
+ Granularity::Word,
+ count,
+ );
+
+ // TODO: use a transaction
+ view.state.selection = Selection::single(pos, pos);
+}
+
+pub fn move_next_word_end(view: &mut View, count: usize) {
+ let pos = State::move_next_word_end(
+ &view.state.doc().slice(..),
+ view.state.selection.cursor(),
+ count,
+ );
+
+ // TODO: use a transaction
+ view.state.selection = Selection::single(pos, pos);
+}
+
// avoid select by default by having a visual mode switch that makes movements into selects
// insert mode: