Some students like to use space to do indentation. So a lot of code start at the beginning with a continuous repeating space, some are four spaces, some even eight spaces. Uncle can not endure aunt.
Vim has some retab options for indenting all vim-processed documents, but that's barbaric, and we're not going to let vim automatically process all the files.
So the more appropriate way to do this is by hand. You can use the following commands in VIM:
:%s/ /\t/g
Explain:
The first colon is the beginning of the command that must be executed in vim. Just like '/' is the beginning of the lookup command.
% means to operate on each row
s represents replacement
The first '/' represents the content to be replaced (here are four consecutive spaces)
The second '/' means what to replace (here is ' \ t ' is tab)
The third '/' indicates the option of substitution ('/g ' indicates an entire row substitution, '/& ' replaces only the first occurrence of the line)
In Vim inside use ': Help:s ' can see detailed explanation