Indent Finder icon

Indent Finder

3.1/5 1
Freeware   

an application that reads a file and tells you what indentation is used inside the file. #Indentation scanner  #Indentation finder  #Search indentation  #Scan  #Find  #Search  

Description

Free Download

Indentation of external program sources is a common problem. Some people use 2 spaces, some tabulations, some 4 spaces, some (the horror!) mix tab and spaces.

Text editors have usually options helping to deal with the way you indent your files. Pressing tab will insert spaces of tabulations depending on your settings. However, it only works properly with your own files, which have been indented in your own way.

As soon as you start editing external sources, you are likely to face a different indentation. Then your careful editor setting will simply screw up the file you edit unless the guy did use the same indentation as yours. And you may not notice it.

For example if I indent with tab but sets them to be displayed as four columns and if I edit a file indented with 4 spaces, all the lines I create will be indented with tab. They will render fine on my editor, but probably not on someone else's editor.

It is especially annoyhing if you program in python as the indentation is part of the program structure.

I haven't found (yet) an editor that deals properly with this problem. The solution however is simple: the text editor must find the indentation used within a file and tune its settings according to this. This is what Indent Finder does.

The indentation analysis works on any language. It was tested successfully with C, C++, python and Java code.

The current version provides helps for the integration with vim. I hope other editors will pick either the script or the idea, and that auto-detecting indentation will become common amongst text editors. I am releasing the code under the BSD License to encourage this.

The script is written in python because it was quick and easy way to write it. The algorithm is pretty simple, and could be rewritten in C to avoid the small (almost unnoticeable) delay due to the python interpreter starting.

Indent Finder scans each line of the entry file for a space character (white space or tab) repeated until a non space character is found. Such a line is considered to be a properly indented line of code. Blank lines and mixed indentation lines are safely ignored.

Lines coming after a line ending in '\' have higher chance of being not properly indented, and are thus ignored too.

An array stores the number of lines that have a specific indentation: tab, number of spaces between 2 and 8. For space indentation, a line is considered indented with a base of x if the number of spaces modulo x yields zero. Thus, an indentaiton of 4 spaces increases the 2-spaces and the 4-spaces indentation line count.

At the end of the scan phase, the indentation that was used with the highest number of lines is taken. For spaces, to avoid the problemes of multiples like 2 and 4, the highest indentation number is preferred. A lower number is chosen if it reports at least 10% more lines with this indentation.

The step of each indentation increase is also a strong hint of the current indentation of the file. The step will grant a 10 points bonus to the number of spaces used.

Requirements:

· Python

Indent Finder 1.0

add to watchlist add to download basket send us an update REPORT
  runs on:
Windows All
  file size:
48 KB
  filename:
indent_finder-1_1.zip
  main category:
Programming
  developer:
  visit homepage

Context Menu Manager

Customize Windows’ original right-click context menu using this free, portable and open-source utility meant to enhance your workflow
Context Menu Manager

Windows Sandbox Launcher

Set up the Windows Sandbox parameters to your specific requirements, with this dedicated launcher that features advanced parametrization
Windows Sandbox Launcher

4k Video Downloader

Export your favorite YouTube videos and playlists with this intuitive, lightweight program, built to facilitate downloading clips from the popular website
4k Video Downloader

Bitdefender Antivirus Free

Feather-light and free antivirus solution from renowned developer that keeps the PC protected at all times from malware without requiring user configuration
Bitdefender Antivirus Free

7-Zip

An intuitive application with a very good compression ratio that can help you not only create and extract archives, but also test them for errors
7-Zip

Microsoft Teams

Effortlessly chat, collaborate on projects, and transfer files within a business-like environment by employing this Microsoft-vetted application
Microsoft Teams

calibre

Effortlessly keep your e-book library thoroughly organized with the help of the numerous features offered by this efficient and capable manager
calibre

Zoom Client

The official desktop client for Zoom, the popular video conferencing and collaboration tool used by millions of people worldwide
Zoom Client

IrfanView

With support for a long list of plugins, this minimalistic utility helps you view images, as well as edit and convert them using a built-in batch mode
IrfanView

ShareX

Capture your screen, create GIFs, and record videos through this versatile solution that includes various other amenities: an OCR scanner, image uploader, URL shortener, and much more
ShareX

% discount
Zoom Client
  • Zoom Client
  • IrfanView
  • ShareX
  • Context Menu Manager
  • Windows Sandbox Launcher
  • 4k Video Downloader
  • Bitdefender Antivirus Free
  • 7-Zip
  • Microsoft Teams
  • calibre
essentials


Click to load comments
This enables Disqus, Inc. to process some of your data. Disqus privacy policy