dotancohen
dotancohen

Reputation: 31511

VIM: Why are replacement tabs different than Insert-mode tabs

I have a large space-indented file. I replaced the spaces with tabs by way of:

:%s/    /<Ctrl-Tab>/g

However, when I set list I see that the replacement tabs give character ^T instead of my configured .___ ( fromset listchars=tab:._,trail:.). In fact, if I insert a tab in Insert mode then it does show the proper .___, so obviously the two characters are different.

How can I insert a "normal" tab with :s? Thanks.

Upvotes: 1

Views: 85

Answers (1)

Cezary Baginski
Cezary Baginski

Reputation: 2115

Use "\t" in the expression:

:%s/    /\t/g

Also, you may want to replace spaces with tabs in the file with :retab, by setting, eg:

:set ts=8
:set noexpandtab
:retab!

Upvotes: 2

Related Questions