neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 3e3eddc8e742124560fa8b1cc6daa921c7bb4d40
parent 72e619ca92b527140e1323f4e281b7f3ad35f380
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Thu, 10 Aug 2023 17:43:35 +0800

Merge pull request #24639 from zeertzjq/vim-6a500661a9cb

vim-patch:6a500661a9cb,81b8bf5b4a33
Diffstat:
Mruntime/doc/tips.txt | 28++++++++++++++++++++--------
Mruntime/doc/usr_05.txt | 24++++++++++++++++++------
2 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/runtime/doc/tips.txt b/runtime/doc/tips.txt @@ -346,14 +346,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 ============================================================================== diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt @@ -118,15 +118,27 @@ This switches on three very clever mechanisms: *restore-cursor* *last-position-jump* > - autocmd BufRead * autocmd FileType <buffer> ++once - \ if &ft !~# 'commit\|rebase' && line("'\"") > 1 && line("'\"") <= line("$") | exe 'normal! g`"' | endif + augroup RestoreCursor + autocmd! + autocmd BufRead * autocmd FileType <buffer> ++once + \ let s:line = line("'\"") + \ | if s:line >= 1 && s:line <= line("$") && &filetype !~# 'commit' + \ && index(['xxd', 'gitrebase'], &filetype) == -1 + \ | execute "normal! g`\"" + \ | endif + augroup END Another autocommand. This time it is used after reading any file. The complicated stuff after it checks if the '" mark is defined, and jumps to it -if so. The backslash at the start of a line is used to continue the command -from the previous line. That avoids a line getting very long. -See |line-continuation|. This only works in a Vim script file, not when -typing commands at the command-line. +if so. It doesn't do that for a commit or rebase message, which are likely +a different one than last time, and when using xxd(1) to filter and edit +binary files, which transforms input files back and forth, causing them to +have dual nature, so to speak. See also |using-xxd|. + +The backslash at the start of a line is used to continue the command from the +previous line. That avoids a line getting very long. See |line-continuation|. +This only works in a Vim script file, not when typing commands at the +command line. > command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis