Thanks to the input file's dual nature, so to speak, using xxd(1)
to filter and edit binary files makes restoring the cursor position
broken. Fix that by ignoring the appropriate file type in the code
that restores the cursor position.
While there, refactor the code a bit to save a few CPU cycles and
to keep the line lengths in check, and use longer versions of some
of the commands, to make it slightly more consistent and more
understandable to newcomers.
---
runtime/doc/usr_05.txt | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
--
--
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/ff9a5f6f18ed343236cab42c204780fc08377e5d.1691476159.git.dsimic%40manjaro.org.
diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt
index bc68e61b8..acc0f0c6b 100644
--- a/runtime/doc/usr_05.txt
+++ b/runtime/doc/usr_05.txt
@@ -308,10 +308,14 @@ This switches on three very clever mechanisms:
*restore-cursor* *last-position-jump* >
- autocmd BufReadPost *
- \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
- \ | exe "normal! g`\""
- \ | endif
+ augroup RestoreCursor
+ autocmd!
+ autocmd BufReadPost *
+ \ let line = line("'\"")
+ \ | if line >= 1 && line <= line("$") && &ft !~# 'commit' && &ft !=# 'xxd'
+ \ | 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