LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-27-2010, 12:20 PM   #1
darooa2
LQ Newbie
 
Registered: Oct 2010
Posts: 2

Rep: Reputation: 0
Question viminfo and prior cursor position


In my CentOS configuration, when I use vim6.3 to edit a file, then close it, and re-open it, my cursor starts out at the line where I last left off. In my cygwin (on Windows) configuration, when I use vim7.3, I don't get this behavior. The viminfo does exist and does seem to get read (because if I type '0 it will go to my last cursor location - but that is globally and could change the file being edited). I've also looked at the .viminfo file and see it getting updated as expected.

In my .vimrc file, I have this:
Quote:
set viminfo='100,<50,f1,\"500,/100,:100
Note that on the CentOS side if I open foo, then I open bar, then I open foo again, my cursor is in the right place for foo, whereas on cygwin if I do this, my cursor would be at the 1st line of foo.. If I were to type '0, it would actually switch to editing bar and put the cursor where I last left off.

Anyhow, this all boils down to asking how I get my cygwin vim to act like my CentOS vim. I've googled a bit and tried a bunch of things to no avail as of yet, and would greatly appreciate any help you could provide.. Thanks!
 
Old 10-27-2010, 12:56 PM   #2
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
Here is a previous thread that may be of some help:

http://www.linuxquestions.org/questi...in-vim-552503/

Regards,

Fordeck
 
1 members found this post helpful.
Old 10-27-2010, 01:15 PM   #3
darooa2
LQ Newbie
 
Registered: Oct 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Thumbs up

Thanks! That thread definitely helped. Not sure why my initial searching didn't find it - sorry to ask about a question that had already been discussed.. To get this to work, I added this to my .vimrc file:

if has("autocmd")
aug vimrc
au!
" restore cursor position when the file has been read
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "norm g`\"" |
\ endif
aug ENG
endif

Not that it matters, but I wonder why it works on CentOS without that extra stuff in the .vimrc file. Regardless - thanks again..
 
Old 10-27-2010, 01:35 PM   #4
fordeck
Member
 
Registered: Oct 2006
Location: Utah
Posts: 520

Rep: Reputation: 61
I think that without a ~/.vimrc file, vim will use defaults from the global file. For instance Ubuntu stores this file at:

/etc/vim/vimrc

I have a Centos 5.5 which has the vimrc file located in the /etc directory.

Regards,

Fordeck

Last edited by fordeck; 10-27-2010 at 01:39 PM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
related to cursor position ravidangaych Linux - General 1 06-18-2009 04:31 AM
Cursor Global Position boogy Programming 10 04-27-2009 04:59 AM
deletion of line above the cursor position. dina3e Linux - Newbie 1 04-07-2008 09:41 PM
Vim cursor position Tischbein Linux - Newbie 4 03-31-2008 01:32 AM
Remember last cursor position in VIM rangalo Debian 4 05-12-2007 09:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration