Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k
Tweeted twitter.com/#!/StackUnix/status/466878095773806592
Source Link
ma0ho
  • 199
  • 1
  • 4

Right-align comments in vim

I'm writing C code using vim and are searching for a possibility to right-align my comments so that they all end at col 80. To give a short example:

int a = 80; /* initialize a */ int b = 7; /* initialize b */ printf("%d + %d = %d", a, b, a+b); /*calculate the result */ 

should turn into

int a = 80; /* initialize a */ int b = 7; /* initialize b */ printf("%d + %d = %d", a, b, a+b); /*calculate the result */ ^col 80 

I have installed vim-easy-align to do other formattings but did not find out yet how to perform this alignment. Maybe someone knows how?

I do not insist on vim-easy-align. If you have another plugin that does the job.. Just tell me ;).