Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tkshnwesper/harveyindent
One line fix for indentation problems
https://github.com/tkshnwesper/harveyindent
Last synced: 8 days ago
JSON representation
One line fix for indentation problems
- Host: GitHub
- URL: https://github.com/tkshnwesper/harveyindent
- Owner: tkshnwesper
- Created: 2015-08-16T21:28:06.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-16T22:16:30.000Z (over 9 years ago)
- Last Synced: 2023-02-28T07:05:55.416Z (over 1 year ago)
- Language: Python
- Size: 125 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## HarveyIndent
Easily fix indentation issues (defaults made for Python). This script is used as a rescue method in case you start getting indentation errors and you need a quick fix.
## Syntax
#### Basic usage
Suppose your file is named test.py
test.py
```
for i in range(0, 10):
print i
```
Note the incorrect indentation.Run:
`$ python harveyindent.py test.py`It creates a file named `test.hi.py`.
test.hi.py
```
for i in range(0, 10):
print i
```Now running `$ python harveyindent.py test.py` on this input
```
for i in range(0, 10):
print i #~
if i == 9:
print 'done'
```Gives:
```
for i in range(0, 10):
print i #~
if i == 9:
print 'done'
```
Notice the `#~` which informs the script to decrease the indent.#### Defining the indent
You can redefine the default indent by giving an option `-s` for spaces and `-t` for tabs followed by the number of spaces or tabs respectively.
For example,
`$ python harveyindent.py test.py -s 4`
will use 4 spaces as an indent.
`$ python harveyindent.py test.py -t 2`
This will use two tabs as an indent.
#### Changing the default unindent symbol
The default unindent symbol is `#~`. This can be changed by giving an option `-u` followed by the symbol in quotes.
For example,
`$ python harveyindent.py test.py -u "#end"`
#### Coding conventions
While programming, make it a point to add the unindent character wherever necessary. So, if indentation errors start occurring you can just run this script to fix them.
```
for i in range(0, 10):
print i
#endif i == 9:
print 'done'
#end
```