Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • BackTrack 5 R2
  • Wine 1.4 / 1.5.5
  • Mozilla Firefox 12...
  • Ubuntu 11.04
  • Angry Birds 1.1.2.1
  • Ubuntu 10.04.4 LTS
  • Linux Kernel 3.4
  • Ubuntu Manual 10.10
  • Adobe Flash Player...
  • Pidgin 2.10.4
  • Home > Linux > Programming > Assembler Tools

    Indent Finder 1.31

    Download button

    Downloads: 495  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Good (3.5/5)
    17 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Philippe Fremy | More programs
    BSD License / FREE
    September 8th, 2008, 16:43 GMT [view history]
    ROOT / Programming / Assembler Tools

     Read user reviews (0)  Refer to a friend  Subscribe

    Indent Finder description

    Indent Finder computes the indentation being used in a source file or source tree.

    Indent Finder computes the indentation being used in a source file or source tree. Indent Finder software can be used to correctly configure an editor or check source tree indentation consistency.

    Indentation of external sources is a common problem. Some people use two spaces, some four spaces, some tabulations, some (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 fuck 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.

    How it works

    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.

    Usage

    On the command line

    In command line mode, it produces simple output like: space 4 or tab 8. This output can by used in other programs or shell scripts.
    $ python indent_finder.py --separate tests/*.*
    tests/DebugClient.py : space 4
    tests/IOtest.java : space 4
    tests/TestRunner.cpp : space 2
    tests/cml.py : space 4
    tests/diffmodel.cpp : tab 8
    tests/pretty-make.py : tab 8

    Check your source tree:

    $ python indent_checker.py 'space 4' *.py
    Target indentation is: space 4
    Inconsistent indentation for indent_checker.py: tab 8
    Inconsistent indentation for setup.py: tab 8
    Inconsistent indentation for test_indent_checker.py: tab 8
    Inconsistent indentation for test_indent_finder.py: tab 8

    Usage: indent_finder.py [ --separate ] [ --vim-output ] [ --verbose ] file1 file2 ... fileN

    Display indentation used in the list of files. Possible answers are (with X
    being the number of spaces used for indentation):
    space X
    tab 8

    --separate: analyse each file separately and report results as:
    file1: space X
    file2: tab 8

    --vim-output: output suitable to use inside vim:
    set sts=0 | set tabstop=4 | set noexpandtab | set shiftwidth=4

    Requirements:

    � Python


    Product's homepage

    What's New in This Release: [ read full changelog ]

    · The Vim plugin was not working.

      


    TAGS:

    source tree indentation | source file indentation | software development | source | tree | indentation



    HTML code for linking to this page:


    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM