LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-17-2004, 02:10 PM   #1
Medievalist
Member
 
Registered: Aug 2003
Distribution: Dead Rat
Posts: 191

Rep: Reputation: 56
Simple vi question.


On some of my linux boxes, vi remembers where I was the last time I edited a file and takes me to that spot the next time I edit the same file.

On others, it doesn't, and just puts me at the top of the file every time.

How do I configure this behaviour? I like going back to where I last was!

--Charlie
 
Old 11-17-2004, 02:43 PM   #2
anon237
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Put the following in ~/vimrc (or /etc/vimrc to make it global):

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


You could put checks around it, take a look at /usr/share/vim/vim62/vimrc_example.vim (62 could be higher/lower).

Hope this helps.
 
Old 11-18-2004, 11:24 AM   #3
Medievalist
Member
 
Registered: Aug 2003
Distribution: Dead Rat
Posts: 191

Original Poster
Rep: Reputation: 56
That code is already in vimrc, but doesn't seem to work on Red Hat Enterprise Linux machines. It's surrounded by an "if" block, though, that is testing for "autocmd"... I wonder if Red Hat failed to compile vim with autocommand!

Thanks for the help, though - I keep forgetting that vi on linux is usually really vim (for which I thank all ghods, since I have to use real vi on HPUX and vim is better).
 
Old 11-19-2004, 11:45 AM   #4
anon237
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Only way I know of to check is this: $ strings /usr/bin/vim | grep autocmd

On all my machines (5), all with 'autocmd enabled vim' the output is:
doautocmd
+autocmd

I don't believe RedHat would leave it out, it's one of the more powerfull extra's that vim has to offer (compared to vi) and they put it in vimrc (at least they did not take it out).

You probably tried this already, but just in case: Did you try to put the relevant part of the code into your ~/.vimrc? Maybe the /etc/vimrc isn't read (which is something to check out, if so).

It's not much to go on, but maybe it helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu Fluxbox simple question, simple answer? generallimptoes Linux - Software 3 09-26-2005 02:03 PM
Installing Programs - A simple question from my simple mind jmp875 Linux - Newbie 6 02-18-2004 09:03 PM
Hopefully a Simple Question Arcane Kidd Linux - Newbie 5 01-17-2003 04:27 PM
Really Simple Question -- Please help! Cia420 Linux - General 3 05-07-2002 06:42 AM
simple question seeking simple answer enzo250gto Linux - Newbie 1 10-27-2001 04:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:26 AM.

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