I edit all my Python files on a remote Centos server using nano. This seems to work well. Occasionally I need to make a small change that changes the indention over the entire file. Is there an easy way to convert all the one space indents to 4 space etc? I have looked at PythonTidy.py but it seems to change too many things.
Asked
Active
Viewed 399 times
1
-
You can use also some plugin or package to your IDE, as for example remote-edit to Atom or remote-vscode to VSCode among others. – Juan Antonio Jan 04 '18 at 18:33
-
Clarification needed. How does changing the current number of spaces help you in changing indents? Would it not be easier to follow what's already in the file? – Jongware Jan 04 '18 at 18:57
-
I have a long block of code and I decide I want to wrap it in an if statement. – Matt Jan 04 '18 at 19:11
3 Answers
0
Not sure if you would consider switching editors. You can customize VIM so it handles auto indentation and easily set tabs to spaces vice versa using the vimrc file. Vim also has a convenient fix indentation command for your issue.

Dave
- 602
- 5
- 18
0
In you're favorite text editor, use search and replace. Find all the instances of
"\n [^-\s]"
and replace them with
"\n "
As long as it takes the newline and regex as expected, it'll indent all the newlines followed by a space followed by a not whitespace (meaning, it won't change 4 spaces into 7 spaces).

Kyle Fawcett
- 19
- 1
- 3
0
I found this:
Installed python-tools then used reindent.py. Worked absolutely perfect.
Thanks.

Matt
- 57
- 1
- 2
- 9