In the current $VIMRUNTIME/vimrc_example.vim ("Last change: 2014 Nov
05") the following autocommand is defined at lines 73 to 81:
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event
handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the
default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
This results in failing to go back to the last known cursor position if
it was in line 1 but not at start-of-line. (The default position is _at
start_ of line 1.) I have a file with a long first line, in which it
would be extremely useful to me to be able to reload the file with the
cursor correctly positioned in that first line, just like it is if it
happened to be in line 2 or higher when the file was last closed in Vim.
IMHO the first condition (before the &&) should be
either
line("'\"") >= 1
or
line("'\"") > 0
and (again, IMHO) the two-line comment sentence starting "Also" should
be removed.
I see that line() returns zero if the mark is not defined: I suppose
this would be the case for a file which already exists but wasn't edited
with Vim before. In that case (finding the mark not set) it would still
be expected that he cursor be left at its default start-of-file
position, e.g. by sidestepping the g`" in the autocomand.
Best regards,
Tony.
--
"From time to time, as we all know, a sect appears in our midst announcing
that the world will very soon come to an end. Generally, by some slight
confusion or miscalculation, it is the sect that comes to an end."
[G. K. Chesterton (1874-1936)]
--
--
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].
For more options, visit https://groups.google.com/d/optout.