vim – fast indent switching

In vim, if code conventions clash, you may need a quick way to switch the indent width. Here is how you can map your function keys to an indent of 3 or 4 spaces.
Simply add a few lines to your .vimrc file:

"basic settings
"replace tabs with spaces
set expandtab
set shiftwidth=4
set tabstop=4
set softtabstop=0

"map F3 to 3/4 spaces when in normal
nnoremap <F3> :set expandtab tabstop=3 shiftwidth=3 softtabstop=0<CR>
nnoremap <F4> :set expandtab tabstop=4 shiftwidth=4 softtabstop=0<CR>