3

How do I align C preprocessor definitions using vim's Align plugin?

Something like:

#define ORING 'r'
#define OLRING "ring"

where the string 'r' should be aligned with "ring".

I don't find any example like this at http://www.drchip.org/astronaut/vim/align.html#Examples they all use a separator like =.

I have tried :Align \tsp which might work because it aligns on whitespaces, but nothing happens.

Thank you

1
  • Why don't you simply insert a space before 'r'?
    – romainl
    Apr 19, 2016 at 20:51

1 Answer 1

4

You can use :<range>Align \s which will use the white spaces as separators. It will give you the following:

#define   ORING    'r'
#define   OLRING   "ring"

To align only the part between the quotes you can use: :<range>Align \('\|"\).* which means "align starting on ' or " and all characters following it". This gives the following:

#define ORING  'r'     
#define OLRING "ring"  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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