I want to change the indentation in all my existing(!) Python files from 2-space to 4-space shift width. Any suggestions how to do this in Vim?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Note that
:set ts=4 sw=4alone will suffice if you use hard tabs (i.e.noexpandtab), but I assume that’s not the case. It’s still possible to utilize this functionality, though, by temporarily settingnoet:This converts existing spaces to tabs, changes the number of spaces per tab, and reverts to spaces. Note that
retabmay affect sequences of spaces elsewhere in the file.It’s also possible to manually substitute each pair of leading spaces with twice as many:
This approach isn’t as generic, though.