summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/defaults.vim16
-rw-r--r--runtime/doc/usr_05.txt26
2 files changed, 28 insertions, 14 deletions
diff --git a/runtime/defaults.vim b/runtime/defaults.vim
index 67659895f2..6f8deb06ba 100644
--- a/runtime/defaults.vim
+++ b/runtime/defaults.vim
@@ -99,15 +99,19 @@ if 1
" Put these in an autocmd group, so that you can revert them with:
" ":autocmd! vimStartup"
augroup vimStartup
- au!
+ autocmd!
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid, when inside an event handler
- " (happens when dropping a file on gvim) and for a commit message (it's
- " likely a different one than last time).
+ " (happens when dropping a file on gvim), for a commit or rebase message
+ " (likely a different one than last time), and when using xxd(1) to filter
+ " and edit binary files (it transforms input files back and forth, causing
+ " them to have dual nature, so to speak)
autocmd BufReadPost *
- \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
- \ | exe "normal! g`\""
+ \ let line = line("'\"")
+ \ | if line >= 1 && line <= line("$") && &filetype !~# 'commit'
+ \ && index(['xxd', 'gitrebase'], &filetype) == -1
+ \ | execute "normal! g`\""
\ | endif
augroup END
@@ -119,7 +123,7 @@ if 1
augroup vimHints
au!
autocmd CmdwinEnter *
- \ echohl Todo |
+ \ echohl Todo |
\ echo gettext('You discovered the command-line window! You can close it with ":q".') |
\ echohl None
augroup END
diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt
index bc68e61b88..f43b239564 100644
--- a/runtime/doc/usr_05.txt
+++ b/runtime/doc/usr_05.txt
@@ -308,17 +308,27 @@ 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("$") && &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