The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
mail format problem: ali560045 Shell Programming and Scripting 5 06-04-2008 05:52 AM
To convert multi format file to a readable ascii format gaur.deepti UNIX for Dummies Questions & Answers 5 03-25-2008 12:03 PM
CSV format problem ccwq Shell Programming and Scripting 10 08-05-2007 11:16 PM
format problem bebop1111116 High Level Programming 5 10-10-2006 07:41 AM
serial no. format problem unknown2205 UNIX for Dummies Questions & Answers 6 12-05-2005 08:45 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 11-28-2003
Registered User
 

Join Date: Feb 2002
Location: Houston TX
Posts: 123
Question Format Problem with vim

Hi, there. Everyone had a great Thanksgiving?

I have a slice format problem when I am using vim to edit c++ source code. I don't know how to discribe the problem exactly. You see, usually when I use the command "vi hello.cpp" to write a code, it will have the format like this:

Code:
#include <iostream>

using namespace std;

int main()
{
        cout << "hello, world!" << endl;
        
        cin.get();cin.get();
        return 0;
}
Recently, I don't know what I did, when I do the same thing, it becomes like this:

Code:
#include <iostream>

using namespace std;

int main()
{
cout << "hello, world!" << endl;

cin.get();cin.get();
return 0;
}
I mean I could use <tab> to move around the code, but it would be unconvnient. Besides, usually when I used an open parenthesis or bracket, it would remind me to close it. Now the warning is gone, too.

Could anyone help me change vim back to the original setting?
__________________
Powered by HOUSCOUS
Reply With Quote
Forum Sponsor
  #2  
Old 11-28-2003
google's Avatar
Moderator
 

Join Date: Jul 2002
Location: Atlanta
Posts: 740
Take a look in your home directory for a hidden file .exrc This is the vi customization file. Did you by chance delete it? or unwittingly modify it?

Here is a link for more information on setting it up and for customizing your vi options.
Reply With Quote
  #3  
Old 11-28-2003
linuxpenguin's Avatar
Registered User
 

Join Date: May 2002
Location: India
Posts: 295
in the .exrc file you may have a entry like

set tabstop=
or se ts=

which means set the tabstop. You may set it and then check.
also check if your vi is vi and not vim. sometimes vi is aliased to vim or soft linked to vim. in that case your configuration file will not be .exrc. it will be .vimrc

There are a couple of more things that set the tabs
1. autoindent
2. smartindent
3. cindents

to know more of these you can simple type h cindents in the vi editor's command mode i.e. the : mode

hope this helps
__________________
War doesnt determine who is right, it determines who is left
Reply With Quote
  #4  
Old 11-29-2003
Moderator
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,469
I believe smartindent is what you need. Try to enter the command

set smartindent

and see if this is what you want.
Reply With Quote
  #5  
Old 12-04-2003
Registered User
 

Join Date: Feb 2002
Location: Houston TX
Posts: 123
Thank you, guys. I didn't find the .exrc file. I think I might delete or damage it by incident. I think I just install vi again to see what will happen. Thanx again.

HOUSCOUS
__________________
Powered by HOUSCOUS
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0