Vim is very accommodating when it comes to tab Vs. space preferences. As I understand it, the tabstop
setting indicates the width of a tab character. The
Are you changing your white space settings so often you really need a function to manage that? If you are messing with tabstop a lot and also setting expandtab, you are probably going to have a mess over time as you change files with different values passed to stab
. Today I use :call stab (4)
, tomorrow it's :call stab (2)
and last week it was :call stab (8)
. Sounds like even if you write it, you'll soon stop using it.
If you plan to always pass the same value to stab, why not just edit your global settings? In vim:
:e $MYVIMRC
and add the following:
set tabstop=4
set shiftwidth=4 "tabs are 4 spaces wide (default = 8)
set expandtab "Convert tabs to spaces
This is how my .vimrc is setup.