Change tab size to 4

forum members,

gvim version 6.0.150.0

Vi has been my favorite editor for over 30 years. Mostly with
Unix but now with windows XP. It works fine but I want to
change the tab to 4 spaces instead of 8. I read on the internet
that I can edit the .vimrc file but I only have an _vimrc file
and windows has a problem with files that start with a ".".

I do have a vimrc_example.vim and gvimrc_example.vim files.

Any suggestions?

jerryd

What happens if you edit _vimrc file? It works fine here.

Try putting in line :set nu to see if the file is being read (line numbers show).

hanson44,

Thanks for the reply.

I entered this line in the _vimrc file ":set nu" but line
numbering didn't happen. I even re-booted. Maybe I have
something set up wrong and Gvim never looks at this file.
Any more suggestions?

jerryd

I normally just use vim. But I also have gvim installed. When I start it, with the "set nu" line in _vimrc, it displays the line numbers. So gvim works fine here, reads _vimrc file.

Make sure just enter "set nu" (NO COLON) in the _vimrc file. The colon is just if entered manually from within vim. I was not clear about that.

I have the path to the vim directory in my PATH variable. Not sure if that needed to find _vimrc file.

Finally, you can edit the gvim icon and add "-u path_to_vimrc" segment after command name, and that might fix problem.

I've tried all your suggestions and no luck so far. Is there some way I could tell for sure if the _vimrc file is being read at all?

jerryd

Reality-Check vim by entering :set nu and verify it shows line numbers.

Make sure _vimrc has the single line:

set nu

Start gvim. If the display does NOT show the line numbers, then your _vimrc is not being read (unless something I'm missing).

What happens when you edit the gvim icon to add path to _vimrc file with -u option?

What happens when you run vim from command window?

BTW, it seems (by my testing) that vim on DOS will also use _exrc if _vimrc is not present. This probably does not solve the current problem, just something to be aware of in case it comes up.

Any odd chance some permissions problem with _vimrc file? I know, unlikely.

forum,

Tried both ":set nu" and "set nu" neither showed line numbers.
Before I try other things I noticed these lines in the _vimrc file.

set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

Do these have anything to do with my problem?

jerryd

It turns out that, as usual, vim has incredibly helpful diagnostic info:

From within vim or gvim, try the following:

:echo $HOME 
:echo $VIM 
:echo $VIMRUNTIME
:version

Open vimrc file - Vim Tips Wiki has more details

Just saw your post. My _vimrc does not have those source and behave lines.
It does have the nocompatible line.

Yes, those lines could well be the cause of the problem. You could comment them out as follows, and see what happens.

 " behave mswin

Are you saying :set nu does NOT show the line numbers when you manually enter from within vim or gvim?

forum,

I commented out all those lines with no change.
I made an _vimrc file with only the line ":set nu" and again
with only "set nu", neither worked.

I don't know how to enter "set nu" directly into gvim and can't
find a place to set the path.

Keep giving me things to try and we'll figure this out.

jerryd

My gvim (I normally just use vim) works the same as vim, along with the added menu at top.

You should be able to type :set nu command directly into gvim. The colon moves you to ex mode so you will see the : at the bottom. Then type in set nu command (set nu) and press ENTER. Hopefully, the line numbers appear!

Once that works, you should be able to type in the other diagnostic commands like :version and the others, to figure out where gvim thinks _vimrc lives.

According to that article, you can even directly edit the _vimrc file, whichever one vim is using, from within vim or gvim, with :e $MYVIMRC command.

The _vimrc lines do NOT start with : colon. The : is only needed from within vim, to switch to ex mode.

On UNIX Systems, vi (and ex) will look for the EXINIT environment variable. If it is set, it names a file containing ex commands. If the file exists, is readable, and the file's owner matches the current process's UID; then vi will read initialization commands from that file. If not; vi will look for the file .exrc in the user's home directory. After that, vi will look for .exrc in the current directory.

On Windows, it could be looking for _exrc instead of .exrc. With vim instead of vi, it could also be looking for .vimrc or .virc (or _vimrc or _virc) instead of or in addition to .exrc (_exrc).

If you can figure out which file your vi or vim is trying to read, the command you want to add to that file is:

set tabstop=4

If you can't figure out which initialization file to use, you can always enter the command:

:set tabstop=4

any time you're in command mode during your editing session to set the tabstops being used for your current editing session.

Forum,

So with all the replies I have found that my $HOME directory
is pointed at c:\documents and settings\owner and if I put
a copy of the _vimrc file there everything works. Now how
do I change the path to $HOME?

jerryd

Why do you want to change the path to $HOME? I would advise not trying to change. Is there something not working at this point? If it's reading the _vimrc file, I might just be satisfied and leave well enough alone.

If you want the _vimrc file somewhere else, run the :version command and see the other possible places to locate the file. It will read whichever one it finds first. On my system, it gives three options:

   system vimrc file: "$VIM\vimrc"
     user vimrc file: "$HOME\_vimrc"
 2nd user vimrc file: "$VIM\_vimrc"