aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs30
1 files changed, 30 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);