I changed python-indent from 3 to 4. I then mark-whole-buffer and indent-for-tab-command. It gave me garbage.
There is the indent-region function. So I'd try mark the whole buffer, then M-x and type indent-region. It's usually bound to C-M-\, as far as I know.
Edit
Re-indentation does not work for a tab-width change. As I wrote in the comments changing spaces to tabs and then altering the tab-width is a solution:
"Guessing you are indenting with space and not tabs, you'd first do tabify on the buffer content with your tab-width set to 3. Then change tab-width to 4 and run untabify."
This is kind of a hack, but it won't give you the garbage that indent-region is giving you
1) Make sure tabs as spaces are set to 4 spaces. In a scratch buffer type:
(setq tab-width 4)
And then evaluate it by marking it and using M-x eval-region
2) Globally replace all sets of three spaces with a tab character
M-x replace-regexp [SPC][SPC][SPC][RET] C-q[TAB][RET]
3) Highlight the whole buffer and untabify
M-x mark-whole-buffer M-x untabify
This will convert all tabs into four 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