Add the function shown in the r-spaces.vim
file to your .vimrc
file.
A possible mapping could be:
" mapping to fix code in normal mode (with motion: e.g. <leader>ip)
nmap <silent> <leader>x :set opfunc=FixFormatting<CR>g@
" mapping to fix a line of code in normal mode
nnoremap <silent> <leader>xx :normal <leader>x_<CR>
" mapping to fix code in visual selection