tags:

views:

22

answers:

1

You can push things to buffer with ^Q and pop them with ESC-g. Alt+x vi-set-buffer changes buffer somehow. How can I see all the buffers? They are probably some files to look at.

+1  A: 

^Q (and Esc-Q) and Esc-g work with an emacs buffer, so I don't think they interact with the vi buffers.

This works in emacs mode (set -o emacs):

function _showbuffers()
{
    local nl=$'\n' kr
    typeset -T kr KR $'\n'
    KR=($killring)
    typeset +g -a buffers
    buffers+="      Pre: ${PREBUFFER:-$nl}"
    buffers+="  Buffer: $BUFFER$nl"
    buffers+="     Cut: $CUTBUFFER$nl"
    buffers+="       L: $LBUFFER$nl"
    buffers+="       R: $RBUFFER$nl"
    buffers+="Killring:$nl$nl$kr"
    zle -M "$buffers"
}
zle -N showbuffers _showbuffers
bindkey "^[o" showbuffers

To demonstrate it, try each of these steps, pressing Alt-o (letter "O") or Esc-o after each one:

  • To show the cut buffer, type echo abc then press Ctrl-u
  • To show the kill ring (the previous cut buffer moves there), type echo def then press Ctrl-u (or Home Ctrl-K or Ctrl-X Ctrl-K)
  • To show the pre buffer, type echo 'ghi, press enter, type jkl'
  • Press enter to execute the previous command and clear the current buffer (don't forget to press Alt-o to see the change)
  • To show the L and R buffers, type echo "mno pqr" and press the left arrow a couple of times
Dennis Williamson
"To show" means "to demonstrate" since all the included buffers are shown with each invocation.
Dennis Williamson