Aligning C function parameters with vim

updated: now saves/retores the paste register

It has bothered me for a while, some coding styles, most notably in the GNOME world try to enforce good looking alignment of functions parameters such as:

static UniqueResponse
on_unique_message_received (UniqueApp         *unique_app,
                            gint               command,
                            UniqueMessageData *message_data,
                            guint              time_,
                            gpointer           user_data)
{
}

Until now, I aligned the arguments by hand, but that time is over! Please welcome my first substantial vim plugin: it defines a GNOMEAlignArguments command to help you in that task. All you have to do is to add this file in your ~/.vim/plugin directory and define a macro in your ~/.vimrc to invoke it just like this:

" Align arguments
nmap ,a :GNOMEAlignArguments<CR>

HTH.

9 thoughts on “Aligning C function parameters with vim

  1. Pingback: Tweets that mention Damien Lespiau » Aligning C function parameters with vim -- Topsy.com

  2. thilahute

    Hi,

    Is there a way to make it aligne parameters in function calling?

    eg:
    output_stream = gdata_upload_stream_new (GDATA_SERVICE (service),
    SOUP_METHOD_POST,
    upload_uri,
    NULL,
    title)
    l
    output_stream = gdata_upload_stream_new (GDATA_SERVICE (service),
    SOUP_METHOD_POST,
    upload_uri,
    NULL,
    title)

    It would be awesame :D

    Anyway thanks lot for this cool plugin

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>