Skip to content

Use shift+k and shift+j to select prev/next of same kind#113

Open
pheki wants to merge 1 commit intoarxanas:mainfrom
pheki:pheki/push-mwutswlxzoyl
Open

Use shift+k and shift+j to select prev/next of same kind#113
pheki wants to merge 1 commit intoarxanas:mainfrom
pheki:pheki/push-mwutswlxzoyl

Conversation

@pheki
Copy link
Copy Markdown
Contributor

@pheki pheki commented Jun 7, 2025

This would also fix jj-vcs/jj#5867

My workflow is basically:

  • Unfold file (f)
  • Go to first section (j / l / shift+right / shift+l)
  • Review each section using Fn+Down/Fn+Up and space (this is where PageDown/PageUp are located on my keyboard)
  • Go back to file (shift+h ideally, but I was using shift+right because it wasn't working, see Fix shift+h and shift+l #112)
  • Fold file (f)
  • Next file (j)

It's all very messy, moving the hand all the time and switching between Fn and Shift gets very confusing

With this my workflow becomes:

  • Unfold file (f)
  • Go to first section (j / l / shift+l)
  • Review each section using shift+j/shift+k and space
  • Go back to file (shift+h)
  • Fold file (f)
  • Next file (j)

A lot simpler! Just shift and the main keyboard keys.

I opened it separately from #112 as that one is just a bugfix, probably easier to be reviewed and merged than this one.

@emesterhazy
Copy link
Copy Markdown
Collaborator

This seems like a good idea to me. In fact, we should probably deprecate page up and page down and add shift up / down as well.

I think this PR needs two things before we can merge it:

  1. We should update the help dialogue
    fn draw(&self, viewport: &mut Viewport<Self::Id>, _: isize, _: isize) {
    let title = "Help";
    let body = Text::from(vec![
    Line::from("You can click the menus with a mouse, or use these keyboard shortcuts:"),
    Line::from(""),
    Line::from(vec![
    Span::raw(" "),
    Span::styled("General", Style::new().bold().underlined()),
    Span::raw(" "),
    Span::styled("Navigation", Style::new().bold().underlined()),
    ]),
    Line::from(
    " Quit/Cancel q Next/Prev j/k or ↓/↑",
    ),
    Line::from(" Confirm changes c Next/Prev of same type PgDn/PgUp"),
    Line::from(" Force quit ^c Move out & fold h or ←"),
    Line::from(
    " Move out & don't fold H or Shift-← ",
    ),
    Line::from(vec![
    Span::raw(" "),
    Span::styled("View controls", Style::new().bold().underlined()),
    Span::raw(" Move in & unfold l or →"),
    ]),
    Line::from(" Expand/Collapse f"),
    Line::from(vec![
    Span::raw(" Expand/Collapse all F "),
    Span::styled("Scrolling", Style::new().bold().underlined()),
    ]),
    Line::from(" Edit commit message e Scroll up/down ^y/^e"),
    Line::from(" or ^↑/^↓"),
    Line::from(vec![
    Span::raw(" "),
    Span::styled("Selection", Style::new().bold().underlined()),
    Span::raw(" Page up/down ^b/^f"),
    ]),
    Line::from(
    " Toggle current Space or ^PgUp/^PgDn",
    ),
    Line::from(" Toggle and advance Enter Previous/Next page ^u/^d"),
    Line::from(" Invert all a"),
    Line::from(" Invert all uniformly A"),
    ]);
  2. Update CHANGELOG.md

Let's not remove page up and page down yet, but would you also add shift up and shift down keybinds?

@pheki pheki force-pushed the pheki/push-mwutswlxzoyl branch from 285cd69 to e442a22 Compare February 7, 2026 01:44
@pheki
Copy link
Copy Markdown
Contributor Author

pheki commented Feb 7, 2026

Ok, so there's a bit of a challenge here, if we just leave all 3 of them the line ends waaay too big (and if the terminal screen is too narrow for the dialog, it panics with:

thread 'main' (39737) panicked at scm-record/src/render.rs:218:10:
called `Result::unwrap()` on an `Err` value: UnsatisfiableConstraint

So I removed PgDn/PgUp from the dialog and it's smaller (although still bigger than other lines). There are alternatives, like separating next/prev (a bit less consistent with the rest of the menu), etc.

Also, I just realized, is there a reason scroll is at ^y/^e instead of ^j/^k? It would be very practical that way haha.

PS.: I had no idea there was a help dialogue, when mentioned I tried h (standard to unix utilities such as less) and had to look into the source to figure it was ?, even though I think I have seen ? in TUIs the past, just forgotten. Maybe there could be a reference to it in the menu?

@emesterhazy
Copy link
Copy Markdown
Collaborator

There's actually another PR open to add a Help menu item to make it easier to find the help dialogue.

I'll have to play around with this to see how easy it is to trigger a panic. Shortening the dialogue sounds reasonable to me. Maybe we should even just remove the page up / page down keybindings, but I guess we can hold off on it since we aren't planning to repurpose them.

RE: ^y/^e, I'm not sure. Something to think about for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR: vi-movement keys for next/previous item of same kind

2 participants