I am picking a simple example from the vim help documentation itself so you can quickly understand what is going on.
Suppose you want a quick way of inserting today's date below your current cursor position. EG:
cursor was here| "Now hitting leader followed by 2 d keys will print the line below
Date: Tue Mar 17 16:11:47 IST 2015
Here is the mapping you can define in your ~/.vimrc
map <leader>dd oDate: <Esc>:read !date<CR>kJ
I will try to break down what the above key mapping does does in the steps below.
Leader is mapped to ** by default. You can optionally change it to any other key. Spacebar** is a good option which can be achieved with the following mapping in my ~/.vimrc file
let mapleader = " "
You can define custom mappings in ~/.vimrc so that they are permanent across your vim sessions.
To define mappings for your current session you can type
:map <leader>dd oDate: <Esc>:read !date<CR>kJ
which will save your mapping for the current session.
If you define new mapping in your ~/.vimrc, you may need to run
in your current shell for your new mappings to reflect.