How to remove TABs from source files
I recently took over a C++ project that was indented inconsistently. Some lines had TABs, most had spaces; so I decided to remove all TABs from the files. vim to the rescue:
:args *.cpp *.h
:set tabstop=2 expandtab
:argdo retab | update
Done.
Explanation:
-
:args
sets the file list to all source files I want to change -
:set
sets up the number of spaces I want to replace the TABs with -
:argdo
executes theretab
andupdate
(i.e. save if changed) commands for each file in the file list
Written by Beat Bolli
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#