diff --git a/internal/action/actions.go b/internal/action/actions.go index c0f4aead8..5abed5bb3 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -2064,14 +2064,17 @@ func (h *BufPane) MouseMultiCursor(e *tcell.EventMouse) bool { return true } -// SkipMultiCursor moves the current multiple cursor to the next available position -func (h *BufPane) SkipMultiCursor() bool { +// SkipMultiCursor moves the current multiple cursor to the next or previous available position, depending on the argument `forward`. +func (h *BufPane) skipMultiCursor(forward bool) bool { lastC := h.Buf.GetCursor(h.Buf.NumCursors() - 1) if !lastC.HasSelection() { return false } sel := lastC.GetSelection() searchStart := lastC.CurSelection[1] + if !forward { + searchStart = lastC.CurSelection[0] + } search := string(sel) search = regexp.QuoteMeta(search) @@ -2079,7 +2082,7 @@ func (h *BufPane) SkipMultiCursor() bool { search = "\\b" + search + "\\b" } - match, found, err := h.Buf.FindNext(search, h.Buf.Start(), h.Buf.End(), searchStart, true, true) + match, found, err := h.Buf.FindNext(search, h.Buf.Start(), h.Buf.End(), searchStart, forward, true) if err != nil { InfoBar.Error(err) } @@ -2099,6 +2102,16 @@ func (h *BufPane) SkipMultiCursor() bool { return true } +// SkipMultiCursor moves the current multiple cursor to the next available position +func (h *BufPane) SkipMultiCursor() bool { + return h.skipMultiCursor(true) +} + +// SkipMultiCursorBack moves the current multiple cursor to the previous available position +func (h *BufPane) SkipMultiCursorBack() bool { + return h.skipMultiCursor(false) +} + // RemoveMultiCursor removes the latest multiple cursor func (h *BufPane) RemoveMultiCursor() bool { if h.Buf.NumCursors() > 1 { diff --git a/internal/action/bufpane.go b/internal/action/bufpane.go index 40fb7cf19..019e4b773 100644 --- a/internal/action/bufpane.go +++ b/internal/action/bufpane.go @@ -841,6 +841,7 @@ var BufKeyActions = map[string]BufKeyAction{ "RemoveMultiCursor": (*BufPane).RemoveMultiCursor, "RemoveAllMultiCursors": (*BufPane).RemoveAllMultiCursors, "SkipMultiCursor": (*BufPane).SkipMultiCursor, + "SkipMultiCursorBack": (*BufPane).SkipMultiCursorBack, "JumpToMatchingBrace": (*BufPane).JumpToMatchingBrace, "JumpLine": (*BufPane).JumpLine, "Deselect": (*BufPane).Deselect, diff --git a/runtime/help/keybindings.md b/runtime/help/keybindings.md index 0f327ea63..140723f0a 100644 --- a/runtime/help/keybindings.md +++ b/runtime/help/keybindings.md @@ -270,6 +270,7 @@ SpawnMultiCursorSelect RemoveMultiCursor RemoveAllMultiCursors SkipMultiCursor +SkipMultiCursorBack None JumpToMatchingBrace Autocomplete