After reading https://stackoverflow.com/questions/7338794/vim-regex-replace-with-n-characters, I've known how to replace tabs by spaces:
The command above allows me to replace n tabs at the beginning of each line with n four-spaces.
Now I want to inverse it: replace n four-spaces with n tabs, I think the command should be
:%s/^\v( )*/\=repeat("\t",strlen(submatch(0)))/g, but it doesn't work: if there is one four-space, it will be replaced by four tabs after executing the command.
Besides, is it possible to get the length of tab of vim so that I can make the command as below?
ATTENTION: I only want to replace the spaces at the beginning of each line.