Format Problem with vim


 
Thread Tools Search this Thread
Top Forums Programming Format Problem with vim
# 1  
Old 11-28-2003
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?
# 2  
Old 11-28-2003
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.
# 3  
Old 11-28-2003
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
# 4  
Old 11-29-2003
I believe smartindent is what you need. Try to enter the command

set smartindent

and see if this is what you want.
# 5  
Old 12-04-2003
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Date Format Problem

I have written a code in Linux environment which compares two dates and print "correct" if 1st date is less than 2nd date. But when I'm running the same code in SunOS environment, "date -d is an illegal format" is the error it is throwing. How different should my code be so that it executes well in... (18 Replies)
Discussion started by: Chandan_Bose
18 Replies

2. UNIX for Dummies Questions & Answers

Vim Match problem

Goodmorning, I've some problem in using regular expression in a VIM syntax configuration file. I've need to match a string as <<< some to match >>> so that it matches only some to match . With standard regular expression i know that for this goal works fine the regex: (?<=<{3}).*(?=>{3}) ... (4 Replies)
Discussion started by: keltron
4 Replies

3. UNIX for Dummies Questions & Answers

Problem to map VIM cursor moving in InsertMode

Hi all What I want? I want in Insert mode, press Alt-hjkl move cursor, and then back to insert mode. I know ctrl-o, hjkl can do the job. but everytime I want to move, i have to press ctrl-o, or I have to count how many hjkl I will do, do a C-O (n)hjkl. What I tried (example only with 'j')... (2 Replies)
Discussion started by: sk1418
2 Replies

4. Solaris

Very Importan - Vim Settings - Error while opening a File using vim

I downloaded vim.7.2 and compiled the vim source . Added the vim binary path to PATH (Because iam not the root of the box) when i load the file using vim it throws me an error Error detected while processing /home2/e3003091/.vimrc: line 2: E185: Cannot find color scheme darkblue line... (0 Replies)
Discussion started by: girija
0 Replies

5. Shell Programming and Scripting

Format problem

can any one know that how can i get perfect format of phone number my function is phone_number=`echo $name_number | awk '{print $NF}'` check=`echo $phone_number | egrep -c "--"` i get the format but if i need perfect format like xxx-xxx-xxxx. if i enter not in this format it still... (1 Reply)
Discussion started by: tarunsavalia
1 Replies

6. UNIX for Dummies Questions & Answers

encountering problem with vim

while entering into vim insert mode some garbage is getting printed in to the file could some one help to avoid this . (1 Reply)
Discussion started by: Gopi Krishna P
1 Replies

7. Shell Programming and Scripting

mail format problem:

i need to send 2 diff mail in a single script:Below the script #!/bin/ksh echo "enter the number" read num if then mail -s "test" unix@yahoo.com mail -s "test" 9886767000@nma.vodafone.in,9916138003@nma.vodafone.in else echo "test again" fi... (5 Replies)
Discussion started by: ali560045
5 Replies

8. Shell Programming and Scripting

Vim problem

Can someone explain me why sometimes the cursor can not be moved to needed position? for example: mysql -u root db -sBe "ALTER TABLE $i ENGINE=$ENGINE"; echo -e "${GG}OK${BB}"; In this line I can not go to position after $i, why? This is not first time I see such issue. "INSERT" pressed :) (0 Replies)
Discussion started by: mirusnet
0 Replies

9. Shell Programming and Scripting

CSV format problem

studentNo=$1 tmp=/tmp/acc2courses$ID.$$ grep -w "$studentNo" CSE1001 >/dev/null 2>&1 && echo CSE1001 >>$tmp grep -w "$studentNo" CSE1002 >/dev/null 2>&1 && echo CSE1002 >>$tmp grep -w "$studentNo" CSE9001 >/dev/null 2>&1 && echo CSE9001 >>$tmp This is my code, The output in tmp file... (10 Replies)
Discussion started by: ccwq
10 Replies

10. Programming

format problem

hey everyone, Im making a program that prints different patterns using * like this: * *** ***** ******* ***** *** * i am letting the user decide what the number of rows can be, i want the shape to appear on the left (60 spaces from the right) if it is even and on... (5 Replies)
Discussion started by: bebop1111116
5 Replies
Login or Register to Ask a Question