Code formatting and indentation in VIM
Answer:
Vim support code formatting and auto indentation - if you tell Vim to know the filetype (either by file extension, or by setting the filetype)
e.g. A simple C program (test.c)
#include
main()
{
for(int i=0;i<10;i++)
{
printf ("Hello World!\n");
}
}
Then type following in Vim command mode (by pressing Esc):
gg=G
Now the code will be formatted to:
#include
main()
{
for(int i=0;i<10;i++)
{
printf ("Hello World!\n");
}
}