The code in both cli/src/commands/{next,prev}.rs is identical except for the direction of movement. This commit pull the parts that make sense out into cli/src/movement_util.rs so it's easier to see the differences. Part of #3947