I have recently installed the c.vim plugin. The only issue is when I type \im (automatically adds the main function) this is the way how it displays it.

main ( int argc, char *argv[] )
        return EXIT_SUCCESS;
}                               /* ----------  end of function main  ---------- */

As you can see it looks a bit messy (I think so at least!). Because of this is there a way how I can format it like this?

int main ( int argc, char *argv[] )
    return EXIT_SUCCESS;

To me this is much neater which is why I want to change it.

  • You'll have to patch the templates coming from c-support or use another plugin which will propose other snippets. Commented Mar 5, 2015 at 21:59
  • Thanks, I have tried looking at the templates but I cannot find the one I like. Do you know where it is?
    – iProgram
    Commented Mar 6, 2015 at 11:32
  • IIRC, the documentation explains how to override a template. Search for "local template". NB: You can also hack in to the templates packaged but it won't be a good idea. Commented Mar 6, 2015 at 12:28
  • I have looked at the local template in search however I am not sure what to do. Could you give me the instructions please?
    – iProgram
    Commented Mar 7, 2015 at 15:44
  • Sorry. I can't do more. So far, I've just grasped hints of a solution from the documentation -- and the way template expander could be implemented. As I said in another Q/A, I'm not using c-support as I'm maintaining a concurrent C++ suite -- which would expand main<c-space> into something closer to what you are looking for, and if not, this time I'll know how to override cpp/main snippet. Commented Mar 7, 2015 at 20:59

1 Answer 1


You need to edit c-support/codesnippets/main.c for C code and c-support/codesnippets/main.cc for C++

Otherwise it looks like the local version is stored in ~/.vim/bundle/cvim/c-support/templates

There is a file called c.idioms.template that contains the main function.


I'm using pathogen so my path looks a little different. Per the c.vim documentation

The master template file is '$HOME/.vim/c-support/templates/Templates' for a user installation and '$VIM/vimfiles/c-support/templates/Templates' for a system-wide installation (see csupport-system-wide).

More info at :help csupport-templates-files

  • Thanks for the reply. Will look into this soon. Where is $VIM (on a Mac)? I know $HOME is ~/ but not where $VIM/ .
    – iProgram
    Commented Mar 11, 2015 at 16:33
  • 1
    Not sure on the Mac, Linux is /usr/share/vim typically. Probably pretty similar location.
    – jecxjo
    Commented Mar 11, 2015 at 16:35
  • I edited c-support/codesnippets/main.cc but it didn't work so I edited the c.idioms.template file and it worked. Thanks.
    – iProgram
    Commented Mar 11, 2015 at 17:38

Your Answer

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

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