aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorPabloMansanet2021-06-29 12:54:16 +0000
committerBlaž Hrastnik2021-06-29 15:56:19 +0000
commitde8745aea772fb03ffc36fd3f959d8aa7ca1fd57 (patch)
tree71a197bc7d40c8fdb4c8e9a78c5ed40b05d7e2ba /helix-term/src
parent73572b77802d5ae2f31b5f060170c89b79c4ff67 (diff)
Incorporate long word commands into keymap
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs39
-rw-r--r--helix-term/src/keymap.rs4
2 files changed, 43 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index f6511ba5..c3f0f392 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -158,6 +158,9 @@ impl Command {
move_next_word_start,
move_prev_word_start,
move_next_word_end,
+ move_next_long_word_start,
+ move_prev_long_word_start,
+ move_next_long_word_end,
move_file_start,
move_file_end,
extend_next_word_start,
@@ -434,6 +437,42 @@ fn move_next_word_end(cx: &mut Context) {
doc.set_selection(view.id, selection);
}
+fn move_next_long_word_start(cx: &mut Context) {
+ let count = cx.count();
+ let (view, doc) = current!(cx.editor);
+ let text = doc.text().slice(..);
+
+ let selection = doc
+ .selection(view.id)
+ .transform(|range| movement::move_next_long_word_start(text, range, count));
+
+ doc.set_selection(view.id, selection);
+}
+
+fn move_prev_long_word_start(cx: &mut Context) {
+ let count = cx.count();
+ let (view, doc) = current!(cx.editor);
+ let text = doc.text().slice(..);
+
+ let selection = doc
+ .selection(view.id)
+ .transform(|range| movement::move_prev_long_word_start(text, range, count));
+
+ doc.set_selection(view.id, selection);
+}
+
+fn move_next_long_word_end(cx: &mut Context) {
+ let count = cx.count();
+ let (view, doc) = current!(cx.editor);
+ let text = doc.text().slice(..);
+
+ let selection = doc
+ .selection(view.id)
+ .transform(|range| movement::move_next_long_word_end(text, range, count));
+
+ doc.set_selection(view.id, selection);
+}
+
fn move_file_start(cx: &mut Context) {
push_jump(cx.editor);
let (view, doc) = current!(cx.editor);
diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs
index 05869610..22731d16 100644
--- a/helix-term/src/keymap.rs
+++ b/helix-term/src/keymap.rs
@@ -186,6 +186,10 @@ impl Default for Keymaps {
key!('b') => Command::move_prev_word_start,
key!('e') => Command::move_next_word_end,
+ key!('W') => Command::move_next_long_word_start,
+ key!('B') => Command::move_prev_long_word_start,
+ key!('E') => Command::move_next_long_word_end,
+
key!('v') => Command::select_mode,
key!('g') => Command::goto_mode,
key!(':') => Command::command_mode,