summaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs30
-rw-r--r--helix-term/src/keymap/default.rs2
2 files changed, 32 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 29648039..beb564ad 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -209,6 +209,8 @@ impl MappableCommand {
move_next_long_word_start, "Move to beginning of next long word",
move_prev_long_word_start, "Move to beginning of previous long word",
move_next_long_word_end, "Move to end of next long word",
+ move_prev_para, "Move to previous paragraph",
+ move_next_para, "Move to next paragraph",
extend_next_word_start, "Extend to beginning of next word",
extend_prev_word_start, "Extend to beginning of previous word",
extend_next_long_word_start, "Extend to beginning of next long word",
@@ -902,6 +904,34 @@ fn move_next_long_word_end(cx: &mut Context) {
move_word_impl(cx, movement::move_next_long_word_end)
}
+fn move_para_impl<F>(cx: &mut Context, move_fn: F)
+where
+ F: Fn(RopeSlice, Range, usize, Movement) -> Range,
+{
+ let count = cx.count();
+ let (view, doc) = current!(cx.editor);
+ let text = doc.text().slice(..);
+ let behavior = if doc.mode == Mode::Select {
+ Movement::Extend
+ } else {
+ Movement::Move
+ };
+
+ let selection = doc
+ .selection(view.id)
+ .clone()
+ .transform(|range| move_fn(text, range, count, behavior));
+ doc.set_selection(view.id, selection);
+}
+
+fn move_prev_para(cx: &mut Context) {
+ move_para_impl(cx, movement::move_prev_para)
+}
+
+fn move_next_para(cx: &mut Context) {
+ move_para_impl(cx, movement::move_next_para)
+}
+
fn goto_file_start(cx: &mut Context) {
if cx.count.is_some() {
goto_line(cx);
diff --git a/helix-term/src/keymap/default.rs b/helix-term/src/keymap/default.rs
index b5685082..a7c1f1de 100644
--- a/helix-term/src/keymap/default.rs
+++ b/helix-term/src/keymap/default.rs
@@ -104,6 +104,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
"c" => goto_prev_class,
"a" => goto_prev_parameter,
"o" => goto_prev_comment,
+ "p" => move_prev_para,
"space" => add_newline_above,
},
"]" => { "Right bracket"
@@ -113,6 +114,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
"c" => goto_next_class,
"a" => goto_next_parameter,
"o" => goto_next_comment,
+ "p" => move_next_para,
"space" => add_newline_below,
},