Search code examples
eclipseperleclipse-cdt

Eclipse Juno for C/C++ Insert space for tab doesn't work


I just found Eclipse Juno for C/C++ "Insert space for tab" doesn't work. Juno for Java works. Anybody has the same issue? Is there a way to run a script to change tabs to 4-spaces in all .cpp and .h files before I check in my changes? Anybody can help with the script? thanks,

Edit:

I am in Linux.

Edit2

this works too:

find ./ -name '*.cpp' -exec sed -i 's/\t/ /g' {} \;


Solution

  • The script is a one-liner from your terminal:

    $ perl -pi.bak -e 's{\t}{    }g' *.cpp *.h
    

    The '.bak' argument will create a backup of your files (e.g. test.cpp --> test.cpp.bak)

    For Windows, use double-quotes instead of single quotes.