In vim, adding the following to your .vimrc should do it:
inoremap <Space><Space> <Tab> inoremap <Space><Space> <Tab> inoremap <Tab> <Space><Space>
The request was: when I press two spaces, I want a tab character to be inputted. I agree that if you want `n` spaces when the tab key is pressed, you should use `expandtab` and `shiftwidth`.Of course now my question is why in the seven hells would you want that mapping??