mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 17:21:49 +00:00
Merge pull request #24639 from zeertzjq/vim-6a500661a9cb
vim-patch:6a500661a9cb,81b8bf5b4a33
This commit is contained in:
@@ -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
|
||||
|
||||
==============================================================================
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user