Monday, March 22, 2010

Re: Cursor column on line 1 not remembered

On Mar 18, 11:19 pm, "Benjamin R. Haskell" <v...@benizi.com> wrote:
> On Thu, 18 Mar 2010, Benjamin R. Haskell wrote:
> > On Thu, 18 Mar 2010, Jean Johner wrote:
>
> > > On Mar 17, 6:36 pm, "Brian L. Matthews" <blmatth...@gmail.com> wrote:
> > > > It works for me, but I might be restoring the cursor position
>
> > > Hi Brian,
>
> > > Adding your 8 lines of code in my .vimrc results in good
> > > memorization of cursor column even on line 1.
>
> > > [...]
>
> > I can't speak for Brian, but in my (g)vim at work when I tested
> > yesterday, it worked fine without anything like Brian's autocmd.
>
> Turns out there's something in Gentoo's /etc/vim/vimrc that defeats
> restoring the cursor column:
>
>   " When editing a file, always jump to the last cursor position
>   autocmd BufReadPost *
>         \ if ! exists("g:leave_my_cursor_position_alone") |
>         \     if line("'\"") > 0 && line ("'\"") <= line("$") |
>         \         exe "normal g'\"" |
>         \     endif |
>         \ endif
>
> OpenSUSE (at work) has the non-broken (abbreviated):
>
> if has("autocmd")
>   autocmd BufReadPost *
>       \ if line("'\"") > 0 && line("'\"") <= line("$") |
>       \   exe "normal g`\"" |
>       \ endif
> endif
>
> The difference in the executed commands is subtle:
> g'"
> versus
> g`"
>
> But, perhaps your distribution has something that uses (perhaps inadvertently)
> 'if line("'\"") > 1', for example.  What system are you on, precisely?

Just to be clear... The version in my .vimrc appears to be correct...

autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif

...yet I still experience the issue.

Brett Stahlman

...[snip]...

--
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

To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

No comments: