On Sat, 22 Aug 2020 at 14:55, Tom Ryder <
t...@sanctum.geek.nz> wrote:
>
> On Sat, Aug 22, 2020 at 09:01:56AM +0000, A. Wik wrote:
> >if has("autocmd")
> > au BufLeave * let x=0 | while x<=bufnr('$') |
> >\ if bufexists(x) |
> >\ set buflisted hidden bufhidden=hide |
> >\ endif |
> >\ let x = x+1 |
> >\ endwhile
> >endif " has("autocmd")
>
> >I was wondering...
> >(a) if there is a better way to do it than this script...
>
> Can you explain what you're trying to do?
I'm trying to undo the "nobuflisted" status that some scripts set on
some buffers. In practice, the main thing is to keep the Vim help
buffers from disappearing from ":ls".
I suppose there is no need to iterate through all buffers. Maybe
"bufnr('%') would work to determine the exact buffer to apply the
options to, ie. only the buffer currently being left?
> >(b) whether all the backslashes and pipe characters (|) are really
> >necessary and why.
>
> The pipe characters are necessary to define a concatenated list of
> commands to :autocmd. The backslashes are line-continuation characters
> to break up what would otherwise be a long line.
I know what they do. I was just wondering, because this is not
normally necessary, but I think I understand now -- it is necessary
for concatenation of what would otherwise be limited to a single
command.
> The easiest way to avoid both in this context is to define a function to
> group the commands:
>
> function! MyFunction() abort
> ...
> endfunction
Why the "!" and "abort"?
-aw