Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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()
    return 0;
share|improve this question

1 Answer 1

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


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.