@@ -275,6 +275,8 @@ impl Command {
275275 completion, "Invoke completion popup",
276276 hover, "Show docs for item under cursor",
277277 toggle_comments, "Comment/uncomment selections",
278+ rotate_selections_forward, "Rotate selections forward",
279+ rotate_selections_backward, "Rotate selections backward",
278280 expand_selection, "Expand selection to parent syntax node",
279281 jump_forward, "Jump forward on jumplist",
280282 jump_backward, "Jump backward on jumplist",
@@ -3747,6 +3749,25 @@ fn toggle_comments(cx: &mut Context) {
37473749 doc.append_changes_to_history(view.id);
37483750}
37493751
3752+fn rotate_selections(cx: &mut Context, direction: Direction) {
3753+ let count = cx.count();
3754+ let (view, doc) = current!(cx.editor);
3755+ let mut selection = doc.selection(view.id).clone();
3756+ let index = selection.primary_index();
3757+ let len = selection.len();
3758+ selection.set_primary_index(match direction {
3759+ Direction::Forward => (index + count) % len,
3760+ Direction::Backward => (index + (len.saturating_sub(count) % len)) % len,
3761+ });
3762+ doc.set_selection(view.id, selection);
3763+}
3764+fn rotate_selections_forward(cx: &mut Context) {
3765+ rotate_selections(cx, Direction::Forward)
3766+}
3767+fn rotate_selections_backward(cx: &mut Context) {
3768+ rotate_selections(cx, Direction::Backward)
3769+}
3770+
37503771// tree sitter node selection
37513772
37523773fn expand_selection(cx: &mut Context) {