If you mean inserting boilerplate code or reusable code fragments, you can define mappings, insert mode abbreviations, or use one of the more powerful snippets plugins.
snippets are like the built-in :abbreviate
on steroids, usually with parameter insertions, mirroring, and multiple stops inside them. One of the first, very famous (and still widely used) Vim plugins is snipMate (inspired by the TextMate editor); unfortunately, it's not maintained any more; though there is a fork. A modern alternative (that requires Python though) is UltiSnips. There are more, see this list on the Vim Tips Wiki.
There are also plugins that automatically populate an empty file with a template.
Macros usually mean keystrokes / command sequences recorded in a register, or mappings derived from that. If you want them only for your competitive coding sessions, you can put those into a separate macros.vim
script, and :source
that on demand (vs. putting them directly into ~/.vimrc
). Even sourcing can be automated:
Local config with built-in functionality
If you always start Vim from the project root directory, the built-in
:set exrc
enables the reading of a .vimrc
file from the current directory.
Local config through plugin
Otherwise, you need the help of a plugin; there are several on vim.org; I can recommend the localrc plugin, which even allows local filetype-specific configuration.