" define a function for cycling the tabstops from 2 -> 4 -> 8 -> 2 set ts=4 sw=4 function Toggle_Tab_Width() if &ts == 2 set ts=4 sw=4 elseif &ts == 4 set ts=8 sw=8 else set ts=2 sw=2 endif endfunction " call the funciton via the ex style command ':TG<ret>' command TG call Toggle_Tab_Width() " set up Function-Key-1 to run the function. <F1> normally " invokes help, but you can still get to that via :help. unmap <F1> map <F1> :TG^M " Allow this to work in insert mode too. unmap! <F1> map! <F1> <esc>:TG^Mli