diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-08-10 17:43:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-10 17:43:35 +0800 |
commit | 3e3eddc8e742124560fa8b1cc6daa921c7bb4d40 (patch) | |
tree | c87cde31e81ff6047f537df228a7cfbc50b75cf0 | |
parent | 72e619ca92b527140e1323f4e281b7f3ad35f380 (diff) | |
parent | a51ab112a6fb96aef9d6e05354cfe7d2df7d8ae8 (diff) | |
download | rneovim-3e3eddc8e742124560fa8b1cc6daa921c7bb4d40.tar.gz rneovim-3e3eddc8e742124560fa8b1cc6daa921c7bb4d40.tar.bz2 rneovim-3e3eddc8e742124560fa8b1cc6daa921c7bb4d40.zip |
Merge pull request #24639 from zeertzjq/vim-6a500661a9cb
vim-patch:6a500661a9cb,81b8bf5b4a33
-rw-r--r-- | runtime/doc/tips.txt | 28 | ||||
-rw-r--r-- | runtime/doc/usr_05.txt | 24 |
2 files changed, 38 insertions, 14 deletions
diff --git a/runtime/doc/tips.txt b/runtime/doc/tips.txt index 7d38b1e0f7..88528b0e4e 100644 --- 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 index 8f7e393c02..076a50c582 100644 --- 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 |