What's the best way to convert a tab-indented file into a space-indented one?
I'd like to be able to specify a variable number of spaces per tab replacement.
In other words, in every line that begins with a consecutive sequence of tabs, I'd like replace each tab of the sequence with X spaces, where I get to set X.
I don't mind what tool is used, whether it is AWK, sed, or even Vim.
Anyone know what the best way to do this is?
Update/paraphrase/clarification:The easiest solution on Linux or many Unix systems is to use the expand command.
If you use Vi or Vim to edit your files, you can add the following to your .vimrc file to ensure tabs are always expanded to spaces when editing files:
set expandtab
For more information on Vim and tabs, see Converting Tabs To Spaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With