Going up or down the change list in visual mode is relatively trivial:
xnoremap g; <C-c>g;v'>
xnoremap g, <C-c>g,v'>
Where…
<C-c>
leaves visual mode without triggering side effects,
g;
/g,
jumps to the next [count]
older/newer change,
v'>
makes a visual selection from the cursor to the end of the previous visual selection.
I wrote "relatively" because always using '>
seems shortsighted. You would want to compare line numbers before doing v'>
or v'<
. See :help getchangelist()
.
Also, you would want to reuse the same v
/V
/<C-v>
instead of always using v
. See :help visualmode()
.
The jump list is trickier because it is not limited to the current buffer. It means that you would also need to check if [count]<C-o>
/[count]<C-i>
jumps to another buffer before actually using <C-o>
/<C-i>
. See :help getjumplist()
.
Remarks:
Navigating the jump list or the change list creates even more contexts in addition to those you already have to handle (data flow, code path, project layout, cursor position, current method, etc.) Be careful, it can and will be overwhelming.
You didn't mention a [count]
in your question so I'm wondering if you actually want <C-o>
/<C-i>
and g;
/g,
, meaning the ability to go to the 5th previous change or 3rd next jump, or if you would be content with :help '[
/:help ']
and :help ''
, which can already be used without mapping:
v'[
V''
v<C-o><C-o><C-o>
? Going up or down the change list might be relatively simple but the jump list spans files so it will be trickier.