Vi IMproved

Vim is a text editor written by Bram Moolenaar and first released publicly in 1991. Based on vi editor common to Unix-like systems, it is designed for use both from a CLI and as a standalone application in a GUI. However, I prefer the command line interface. It is my weapon of choice for programming competitions and other everyday stuff. Part of Vim's power is that it can be extensively customized.

Time is an important factor in programming competitions. Since I use C++ to code, it is difficult to write all the header files (although, we can use bits/stdc++.h) and other commonly used macros and functions again and again. Too many ands. To overcome this, I've defined two files .templatec.c for C and .templatecpp.cpp for C++ in my $HOME folder so that I can load them into a new *.c or *.cpp file using Vim.

vimrc

The vimrc file contains optional runtime configuration settings to initialize Vim when it starts. On Unix-based systems, the file is named .vimrc. It is usually placed in the $HOME folder. Here's mine.

autocmd! BufNewFile  .c silent!  0r /path/to/.templatec.c
autocmd! BufNewFile  .cpp silent!  0r /path/to/.templatecpp.cpp
set number
set cindent
set autoindent
set expandtab
set shiftwidth=4
set softtabstop=4
set pastetoggle=
set ruler
set background=dark
g:tex_flavor='latex'
syntax on

The first two lines, as suggested earlier load the defined templates into a new file.

Here are some awesome vimrcs I found: [1] and [2].

Happy Vimming!

Comments!