On Di, 08 Aug 2023, 'Dragan Simic' via vim_dev wrote:
> > This version saves and restores the view position while saving the > buffer, to keep the current view unchanged after doing ":w", which > previously caused the window to scroll back to the very beginning of > the buffer. I believe it's needles to say how annoying and actually > counterproductive that was. > > This version also eliminates the "Press ENTER or type command to > continue" message, which was previously displayed after opening larger > binary files. The use of "silent" and "redraw!" commands is also > tailored specifically to avoid screen flickering, e.g. when doing > ":w", caused by the buffer being filtered by an external command. > > While there, reformat the code to make it more readable, and use longer > versions of the commands, to make it slightly more consistent and more > understandable to newcomers. > --- > runtime/doc/tips.txt | 28 ++++++++++++++++++++-------- > 1 file changed, 20 insertions(+), 8 deletions(-) > > diff --git a/runtime/doc/tips.txt b/runtime/doc/tips.txt > index ea8d538bf..79b1574e2 100644 > --- a/runtime/doc/tips.txt > +++ b/runtime/doc/tips.txt > @@ -431,14 +431,26 @@ comma-separated list of extension(s) you find yourself > wanting to edit: > > > " vim -b : edit binary using xxd-format! > augroup Binary > - au! > - au BufReadPre *.bin let &bin=1 > - au BufReadPost *.bin if &bin | %!xxd > - au BufReadPost *.bin set ft=xxd | endif > - au BufWritePre *.bin if &bin | %!xxd -r > - au BufWritePre *.bin endif > - au BufWritePost *.bin if &bin | %!xxd > - au BufWritePost *.bin set nomod | endif > + autocmd! > + autocmd BufReadPre *.bin set binary > + autocmd BufReadPost *.bin > + \ if &binary > + \ | execute "silent %!xxd -c 32" > + \ | set filetype=xxd > + \ | redraw > + \ | endif > + autocmd BufWritePre *.bin > + \ if &binary > + \ | let s:view = winsaveview() > + \ | execute "silent %!xxd -r -c 32" > + \ | endif > + autocmd BufWritePost *.bin > + \ if &binary > + \ | execute "silent %!xxd -c 32" > + \ | set nomodified > + \ | call winrestview(s:view) > + \ | redraw > + \ | endif > augroup END > > > ============================================================================== Thanks, I think using the long command form makes sense. Best, Christian -- angeln: stundenlang geduldig an einem Fleck lauern, bis man nichts gefangen hat. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/ZNKFVdFYCjzLUYjj%40256bit.org.
