diff --git a/doc/tips.jax b/doc/tips.jax index 53c4b974b..21557b812 100644 --- a/doc/tips.jax +++ b/doc/tips.jax @@ -1,4 +1,4 @@ -*tips.txt* For Vim バージョン 9.0. Last change: 2021 Nov 06 +*tips.txt* For Vim バージョン 9.0. Last change: 2023 Aug 10 VIMリファレンスマニュアル by Bram Moolenaar @@ -435,16 +435,28 @@ NOTE: これを利用するには 'cpoptions' から '<' フラグを外して ともできます。"*.bin" をあなたの編集したいファイルの拡張子の、コンマで区切られ たリストに変えてください: > - " vim -b : edit binary using xxd-format! + " vim -b : xxd 形式を使用してバイナリを編集する! 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 ============================================================================== diff --git a/en/tips.txt b/en/tips.txt index ea8d538bf..0dfddb255 100644 --- a/en/tips.txt +++ b/en/tips.txt @@ -1,4 +1,4 @@ -*tips.txt* For Vim version 9.0. Last change: 2021 Nov 06 +*tips.txt* For Vim version 9.0. Last change: 2023 Aug 10 VIM REFERENCE MANUAL by Bram Moolenaar @@ -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 ==============================================================================