LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-25-2010, 06:16 AM   #1
Triumph
Member
 
Registered: Sep 2007
Location: Cape Town, South Africa
Distribution: Ubuntu
Posts: 36

Rep: Reputation: 15
How to edit vi tab size


Hi all,

I am learning vi and like it so far. I am writing Python code with it and would like to change my tabs from 8 spaces to 4. I saw somewhere that I should edit my .vimrc file and add :set tabstop=4, but I cannot find it (even when I run :version in vi, it tells me where my user and system .vimrc files are, but I cannot find them there).

Any advice please?

Thanks,
Lloyd
 
Old 12-25-2010, 06:31 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

There are a few places you can set preferences:

/etc/vimrc -> This sets the preferences for all user
~/.vimrc -> This set preferences for a specific user (/home/druuna/.vimrc -> for druuna only). This is a . (dot) file, and might not be visible with the normal commands/tools you use. In a terminal use ls -la, the a tells ls to show hidden (dot) files as well.

The .vimrc file is not always present by default, if so you can create it yourself.

BTW: You should use this: set tabstop=4 (or set ts=4). The : is not used/wanted in the vimrc files.

Hope this helps.
 
Old 12-25-2010, 09:53 AM   #3
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hello and merry Christmas,

the default vimrc file resides in the /usr/share/vim/vim73/ directory and is named vimrc_example.vim. You can copy this file to your /home directory
Code:
cp /usr/share/vim/vim73/vimrc_example.vim ~/.vimrc
then you may follow druuna's advice and add "set ts=4" to the file.

Markus

Last edited by markush; 12-25-2010 at 10:10 AM. Reason: typo
 
Old 12-30-2010, 05:05 PM   #4
Triumph
Member
 
Registered: Sep 2007
Location: Cape Town, South Africa
Distribution: Ubuntu
Posts: 36

Original Poster
Rep: Reputation: 15
Thanks!

Hello druuna and markush,

Thank you so much for the accurate and helpful responses. Season's greetings to you both!

Lloyd
 
Old 12-31-2010, 04:49 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
You're welcome
 
  


Reply



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
Having trouble with Zencart Templates - Cold Steel - need to edit main page txt size alwayslearning Linux - Software 0 10-05-2010 03:17 PM
How to edit a logical volume size that is mounted to / linux-who? Linux - Enterprise 5 07-30-2009 12:13 PM
tab in Konsole shows size true_atlantis Linux - Software 5 02-19-2004 11:29 PM
Change size of icons on Alt+tab for KDE via RH9 robertmarkbram Linux - Software 0 10-13-2003 08:48 PM
VI:how do you change tab size? gtanghookup Programming 4 09-26-2003 05:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:55 PM.

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