You are not logged in.

#1 2008-02-15 16:26:45

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

vi cursor position remembered on exit

Hi All

I swear vi used to remember it's cursor position on exit, so next time you opened the file you were where you left off.  This seems to have stopped working, am I missing something?

Thanks smile

Offline

#2 2008-02-15 17:18:29

mfolnovic
Member
From: Zagreb, Croatia
Registered: 2008-01-03
Posts: 104

Re: vi cursor position remembered on exit

It's working here now ... smile

Offline

#3 2008-02-15 18:17:01

F
Member
Registered: 2006-10-09
Posts: 322

Re: vi cursor position remembered on exit

Mine only remembers the line I was last on, not the exact position. Unfortunately I have absolutely no idea where in the .vimrc this is explicitly stated.

Offline

#4 2008-02-15 18:44:34

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: vi cursor position remembered on exit

Well line is better than nothing (it may have been line)

Could one of you post your .vimrc just to see if I can work it out.

Cheers

Offline

#5 2008-02-15 19:25:54

nj
Member
Registered: 2007-04-06
Posts: 93

Re: vi cursor position remembered on exit

  " 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).
  autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal! g`\"" |
    \ endif

Note that the normal command uses the backquote instead of the single quote, which goes to the line and column. Changing it to a single quote will just go to the line.

This code should already be in your /etc/vimrc unless it was modified.

Offline

#6 2008-02-15 20:12:16

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: vi cursor position remembered on exit

Strange, it's working on one box (using testing repo), but not on another (not testing).
Same vim version on both, same config hmm


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#7 2008-02-15 20:34:18

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: vi cursor position remembered on exit

Strange it is in my /etc/vimrc

It works for root!
I wonder why my profile is ignoring it?

On another note, must be related.  When I log into tty1-6 my .bashrc does not get applied, opening urxvt it does.  Didn't worry about it to much until now, but now I think both problems are more than coincedence

Bizarre!

Anyone? wink

Offline

#8 2008-02-15 22:08:42

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: vi cursor position remembered on exit

gazj wrote:

On another note, must be related.  When I log into tty1-6 my .bashrc does not get applied, opening urxvt it does.  Didn't worry about it to much until now, but now I think both problems are more than coincedence

I believe that's expected.
tty1-6 == login shells -> .bash_profile
urxvt == non login shell -> .bashrc

Though it's also possible to enable login shell mode for most terminals
IIRC, for xterm and urxvt, there is a loginShell option which can be put in .Xdefaults


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#9 2008-02-15 22:55:22

peets
Member
From: Montreal
Registered: 2007-01-11
Posts: 936
Website

Re: vi cursor position remembered on exit

I think (haven't checked -- using win32 at work,) I think that ~/.vimrc overrides /etc/vimrc.

Offline

#10 2008-02-16 00:06:34

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: vi cursor position remembered on exit

@shining

Doh - Silly me at sometime I had deleted my .bash_profile.  I had read about that in tty's before somewhere, but had obvioulsy forgot it.  Don't think I will again big_smile  Thanks for that shining

@peets

I have removed my .vimrc but the problem still occurs.  I have also tried copying /etc/virc to ~/.virc and ~/.vimrc it still won't work.  Thank you tho good suggestion.  It's like vi is completely ignoring any configs.  Wierd!!

Offline

#11 2009-06-26 07:44:29

schivmeister
Developer/TU
From: Singapore
Registered: 2007-05-17
Posts: 971
Website

Re: vi cursor position remembered on exit

Let me revive this..

I've found a workaround:

It looks like ~/.viminfo only gets created by root, and you will have one in your user's dir when you use sudo. Changing the ownership and group will resume normal behaviour (cursor position remembered).

But one question:

Why doesn't ~/.viminfo get created for a non-root user?


I need real, proper pen and paper for this.

Offline

Board footer

Powered by FluxBB