Merged code of two functions edit_move_up() and edit_move_down()