Reputation: 89
As a beginner for vim , I met some problem when format my code. Here is a tiny example to explain what I want.The code below is my original file without any formatting.It looks too crowd
#include <stdio.h>
static int global=1;
static void test(int a,int b);
int main(){
int local=1;
int useless=local+1;
printf("hello,world\n");
test(1,2);
}
static void test(int a,int b){
int c=a*b+a-b;
return;
}
I want style look like:
int useless = local + 1;
or
test(1 , 2);
I try :!indent --linux-style %
in command mode and gets
#include <stdio.h>
static int global = 1;
static void test(int a, int b);
int main()
{
int local = 1;
int useless = local + 1;
printf("hello,world\n");
test(1, 2);
}
static void test(int a, int b)
{
int c = a * b + a - b;
return;
}
Though it works, there are two annoying points for me:
So is there other solution ? THX
Upvotes: 0
Views: 2698
Reputation: 89
I try this plugin: https://github.com/vim-autoformat/vim-autoformat
and solved my problem
Upvotes: 0