Friday, January 20, 2023

Re: Why does (my) Vim leave the cursor to the last mark even if I don't save the file?

Am 19/01/2023 um 16:40 schrieb Christian Brabandt:
> On Do, 19 Jan 2023, 'Ottavio Caruso' via vim_use wrote:
>
>> Ok, the title is probably not accurate, so I'll try to explain.
>>
>>
>> Let's say I have a file with 5 lines
>>
>> --------------------------
>>
>> This is line 1
>> Another line
>> More lines
>> Even more lines
>> This is the last line
>>
>> -------------------------
>>
>> I save the file (Esc w q). When I reopen it, the cursor is at the end of
>> line 5.
>>
>> Then I move the cursor up two lines. I quit without saving (Esc q!).
>>
>> When I reopen the file, the cursor is now at the 3rd line.
>>
>> Is this intended behaviour? If so, how can I tell Vim to ignore movements
>> but just this time?
>>
> The behaviour you are seeing, comes from a BufReadPost autocommand, that
> restores the last cursor position. It's defined in the help below
> :h last-position-jump
>
>> $ cat .vim/vimrc
>> source $VIMRUNTIME/defaults.vim
> This is where the auto command is defined. If you do not want it, you
> can delete this after sourcing the defauls.vim file:
>
> :augroup vimStartup | au! | augroup END

Thanks, but if do that, I'd then remove this feature from all files,
whether edited or not, wouldn't I?. Is it possible to have this
implemented only on files that are saved?

--
Ottavio Caruso

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/0b4a48c8-e18c-e563-08e4-30f8a44f0d13%40yahoo.com.

No comments: