These functions can help when working with multiple sessions or with multiple buffers. As you open new buffers in a session, you build a stack of buffers. Each session has its own stack of buffers. ## Edit multiple sessions in the same way These functions apply the same command to multiple sessions. # Apply command to all sessions. # usage: ] function+all { db0 while(*) { e- } while(*) { ~0 e+ } } # Apply command to the current and next sessions. # usage: ] function+allnext { db0 while(*) { ~0 e+ } } # Apply command to the current and previous sessions. # usage: ] function+allprev { db0 while(*) { ~0 e- } } ## Change session These functions go to the first or last session. # Go to the first session. # usage: # This function uses the label z. function+next { db0 H- sg+ sw- kz /~0/f while(?) { 'zX if(*) { } e+ sw+ kz $X if(*) { } /~0/f } } # Find the previous match across sessions. # usage: # This function uses the label z. function+prev { db0 H- sg+ sw- kz ?~0?f while(?) { 'zX if(*) { } e- sw+ kz 1X if(*) { } ?~0?f } } ## Count sessions This function prints the number of sessions. # Print the number of sessions. # usage: sessions function+sessions { db0 var lower=1 e- while(*) { var lower=$(lower+1) e- } var total=1 e+ while(*) { var total=$(total+1) e+ } p $(total) [ $(total) != $(lower) ] while(*) { var lower=$(lower+1) e- [ $(total) != $(lower) ] } var lower=clear var total=clear } ## Quit sessions This function quits sessions until it reaches a session that contains a buffer with unwritten changes. If a buffer has unwritten changes, you can use the `w` command to write the changes to a file. Use the function again to quit the current session and continue quitting sessions. # Quit sessions. # usage: # This function uses the label z. function+sdown { db0 H- sg+ sw- kz /~0/f while(?) { 'zX if(*) { } down sw+ kz $X if(*) { } /~0/f } } # Find the previous match across buffers. # usage: # This function uses the label z. function+sup { db0 H- sg+ sw- kz ?~0?f while(?) { 'zX if(*) { } up sw+ kz 1X if(*) { } ?~0?f } } ## Unstack buffers This function moves each buffer in the stack in the current session to its own session. # Unstack the buffers. # usage: