In VIM this task can be simply done with

:%s/\t/    /g

But how to do it in Emacs? The first command to do replace is query-replace or the M-% key binding. When I call command query-replace, it prompts me input the string needs to be replaced. I just enter \t. But it doesn't work. Found 0 occurrences.

Turns out to do such an task is harder in Emacs than VIM. First, Emacs has no notation of \t to represent tab. In Emacs tab is represent by key binding C-q C-i. So when command query-replace ask for searching string, you should input the key sequence to generate a tab character.

And then input target string, for example four white space. After you have down all these , Eamcs will highlight all occurrences start for current cursor.

And then you have many choices, press y to replace one match, n to skip, q or RET to exit. To replace all occurrences input !.

So to replace all occurrences of a string in current buffer, You press M-% or M-x query-replace then input the target string and then replace string then press !. It needs at least four operations.

This method is so called queried search and replace. For each queried search and replace there is a non-interactive(unconditional) version, replace-string for query-replace and replace-regexp for query-replace-regexp. Its actually not the best way to do the task. Another way is called unconditional search and replace, by command replace-string. Here is how to do it.

M-x replace-string RET C-q C-i RET space space space space RET

We not talk about regular expression search and replace yet which is overkill for such a simple task. I will talk it later.