In zsh, I have alt+. bound to insert-last-word

When I am listing through the last command parameters by repeatedly pressing alt+., sometimes I press one too many and I need to go one back.

What keybinding is used to go back?

1 Answer 1


You can just undo, bound to Ctrl+_ in emacs mode by default (note that insert-last-word is also bound to Alt+_).

After undoing though, if you invoke insert-last-word again, you'll be back to the beginning, you can't just alternate pressing Ctrl+_ and Alt+_ to go back and forth in the history.

For that, you'd need to define a separate widget that invokes the insert-last-word widget with 1 as argument (see info zsh insert-last-word for details).

For instance, bound to Alt+,:

insert-last-word-forward() zle insert-last-word 1
zle -N insert-last-word-forward
bindkey '\e,' insert-last-word-forward
  • the bind on the last line did not work. I had to change that to bindkey. Nov 14, 2018 at 21:07
  • @Martin, sorry, my bad. Fixed now. Nov 14, 2018 at 21:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .