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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
11-17-2004, 02:10 PM
|
#1
|
Member
Registered: Aug 2003
Distribution: Dead Rat
Posts: 191
Rep:
|
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
|
|
|
11-17-2004, 02:43 PM
|
#2
|
LQ Veteran
Registered: Sep 2003
Posts: 10,532
|
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.
|
|
|
11-18-2004, 11:24 AM
|
#3
|
Member
Registered: Aug 2003
Distribution: Dead Rat
Posts: 191
Original Poster
Rep:
|
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).
|
|
|
11-19-2004, 11:45 AM
|
#4
|
LQ Veteran
Registered: Sep 2003
Posts: 10,532
|
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.
|
|
|
All times are GMT -5. The time now is 05:26 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|