how to change the tab size in vi?

the default size is 8. i found it's too big.

how can i change the tab size in vi? is it a good idea to change it at all?

thks

In vi at the ":" prompt type:

for a tab size of 4

Thxs Neo

how to setup for all vi. I mean every time i go into vi, the tab size is 4.
do i want too much?

no problem, just use the your resource file...

Some useful set options for your ~/.exrc file:

:set all Display all Set options
:set autoindent Indent following lines to the indentation of previous line.
:set ts=4 set tab stop to 4 char
:set ignorecase Ignore case during pattern matching.
:set list Show special characters in the file.
:set number Display line numbers.
:set shiftwidth=n Width for shifting operators << and >>
:set showmode Display when in Insert, Append, or Replace mode.
:set wrapmargin=n Set right margin 80-n for autowrapping lines (inserting newlines). 0 turns it off.

Neo,

Where can I find the .exrc file? It doesnt exist in the $HOME directory or the root (/)

You should create it in your $HOME and vi should read it on startup...

After creating the .exrc file in my $HOME dir...

I managed to get vi to read the .exrc file by using the :'source .exrc' command.

But is there a way you can get vi to read it automatically?

Depends..... what login shell are you running?

I'm running in a bash environment.

vi looks for the rc files in the following order:

/etc/vi.exrc
$HOME/.nexrc
$HOME/.exrc
.nexrc
.exrc

If it doesn't use your $HOME/.exrc per default, maybe it loads up /etc/vi.exrc or $HOME/.nexrc first? Check if those exist, and maybe alter those or delete them, if you may.

HTH,
Lexx

Thanks for the info, the only one that exists is the one that I created:
$HOME/.exrc

vi isn't reading it when it starts up.

btw, is exrc an acronym?

Hm, now that is strange. Which system and shell are you using? Any strange environment variables set which could affect this (I can't think of any in particular, just look through them)

'rc' files are usually setup files, and ex is an editor which has something in common with vi, I'm not sure what though, as I have never used it. Apparently, vi seems to be based on this one as it's using the same setup file. Someone correct me if this suggestion is wrong.

Greetings,
Lexx

--
:wq!

Very close.
ex is a line-editor much like ed, but with some better features.
vi was built "on top" of ex - some versions of vi allow you toggle between ex-mode and vi-mode.
An *rc file typically means "run commands", and is sourced (to relate it to a shell function) rather than executed.
So .exrc is the "run commands" config file for ex, that vi reads as well, since vi is dependant on ex. Many of the new incarnations actually incorporate ex and vi in the same executable with hardlinks to each other.
See the full and more acurate history here:
http://www.cs.pdx.edu/~kirkenda/joy84.html

Linked to from the "vi Lovers Homepage":
http://www.thomer.com/vi/vi.html