Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I prefer using vi from tty1 as I hate GUI. I've just begun programming in C and would like to know how to get vi to auto indent for me. I would like the following code to appear just like the way I've typed with proper tab space.

#include <stdio.h>
int main()
{
    printf("hello.\n");
    return 0;
}
share|improve this question
up vote 1 down vote accepted

Put the following lines in ~/.vimrc (use vim :P)

filetype indent on
filetype plugin on
syntax on

It will turn on filetype detection and will automatically get the correct syntax and indentation.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.