Page 1 of 1

[OT] Help with "vim" on Linux

Posted: Wed May 20, 2009 9:58 am
by chulett
Working on my first Linux system where vi is actually vim or "Vi IMproved" under the covers and some of the so-called improvements are making me crazy. Two in particular and curious what my options are, if any:

1) It remembers where I was in every dang file from session to session and puts me back there when I vi it again. I would prefer to just start at the top, is there a setting for this?

2) Search highlighting. Fine, nice and all but how in the heck do you clear them? All I've been able to figure out to do is to then search for something I know it won't find. And it remembers them as well between sessions, exiting and coming back doesn't get rid the dang things.

Thanks.

Posted: Wed May 20, 2009 12:06 pm
by kduke
Does it still use .exrc?

Posted: Wed May 20, 2009 1:50 pm
by chulett
It apparently uses both a ".vimrc" and a ".viminfo", the former is similar and the latter seems to keep all of the history.

Re: [OT] Help with "vim" on Linux

Posted: Wed May 20, 2009 5:43 pm
by sbass1
chulett wrote:1) It remembers where I was in every dang file from session to session and puts me back there when I vi it again. I would prefer to just start at the top, is there a setting for this?
http://durgaprasad.wordpress.com/2007/0 ... m-solaris/

http://ubuntuforums.org/showthread.php?t=209136

So search for BufReadPost in your vimrc?
chulett wrote:2) Search highlighting. Fine, nice and all but how in the heck do you clear them? All I've been able to figure out to do is to then search for something I know it won't find. And it remembers them as well between sessions, exiting and coming back doesn't get rid the dang things.
http://vim.wikia.com/wiki/Highlight_all ... rn_matches

Perhaps rename your .vimrc, and build yours up from scratch?

http://stripey.com/vim/vimrc.html

http://www.vi-improved.org/vimrc.php

(There are others of course...Google for sample .vimrc files and steal and modify until you get one that works for you).

HTH...

Scott

Posted: Wed May 20, 2009 5:48 pm
by chulett
Thanks Scott, I'll check out those links. For the record, i don't actually have a .vimrc file in my home but there may be a global one out there. I do, however, have my very own .viminfo file! Neeto. :wink:

Posted: Wed May 20, 2009 7:39 pm
by sbass1
Look for /etc/vimrc, /etc/vim/vimrc, or /usr/local/share/vim/vimrc.

Or do

Code: Select all

find / -name vimrc
, then go get a cup of coffee :wink:

Or create ~/.vimrc, which should override any global settings.

Code: Select all

:scriptnames
should tell you which initialization files are used.

HTH

Posted: Wed May 20, 2009 7:44 pm
by Kryt0n

Code: Select all

:nohlsearch
turns the highlighting off, however, you will get the highlighting again when you next do a search.

Code: Select all

:let @/ = "" 
seems to do the same.

Supposedly unsetting the "hlsearch" option stops it from happening but I haven't figured out how to set it (have removed the hlsearch entry from .vimrc but still highlights for me... and .viminfo is telling me it is still set).

As for the line it opens on... haven't figured it out...

Posted: Wed May 20, 2009 9:13 pm
by asorrell
If it is Redhat Linux, and you are getting vim when you type vi you can just "unalias vi" to get the original vi command. I'm colorblind, so vim drove me nuts. I just put the unalias vi command in my .bash_profile so it is turned off for me when I login.

Posted: Wed May 20, 2009 9:54 pm
by Kryt0n
To always open a file on the first line, in the .vimrc file, change the "set viminfo=" line to have 0 after the single quote...

Or you could move back to using just vi as per previous comment... but where is the fun in that???

Edit: And to solve the highlighting, add a 'h' on to the viminfo line (remembering it is a comma separated list)

Posted: Wed May 20, 2009 10:10 pm
by chulett
asorrell wrote:If it is Redhat Linux, and you are getting vim when you type vi you can just "unalias vi" to get the original vi command. I'm colorblind, so vim drove me nuts. I just put the unalias vi command in my .bash_profile so it is turned off for me when I login.
Yes, it is RH w/ bash and it's not like I'm typing "vim", I type vi and get vim instead so that unalias sounds like a godsend. I just figured my poor old brain-dead vi was gone for good. [sniff]

And between putty and vim on RH, all of the colors have been a bit much - kind of like going from Kansas to Oz, if you know what I mean. I had to find a custom color scheme that 'worked' for me as the default one drove me nuts and the blue it used made anything blue illegible to me. Ended up with lighter 'desert' colors that are (mostly) palatable.

I'll let you know tomorrow! And sorry Kryt0n but I'm quite at home in vi and have no need for none of them there fancy improvements. One sec, be right back... Damn munchkins, get off my lawn!

:wink:

Posted: Thu May 21, 2009 12:43 am
by aartlett
If you are connecting to the R/Ht system from a Windows box, I like to use UltraEdit by IDM, It was cheap, can access files on the Unix/Linux remote box and becomes a 1 stop editing shop for me. Combined with my favorite File tool (FileCommander) I'm in pig heavin (one without a fllu though).

Just my effective 0 cents (2 cents rounded down because we don't use copper anymore)

Posted: Thu May 21, 2009 5:28 am
by chulett
I have UltraEdit, wasn't aware of the remote access stuff. I'll have to check that out.

Posted: Thu May 21, 2009 2:28 pm
by chulett
asorrell wrote:you can just "unalias vi" to get the original vi command
That worked! Very nice, thanks Andy. :wink: