Search code examples
eclipseeclipse-plugineditordocumenteclipse-pde

Show only part of document in editor


Is it possible to show only a part of a document in a (possible custom) Eclipse editor? There is ITextViewer#setVisibleRegion, but this only scrolls the viewport. I'd like to show only a partition of a given document or (alternatively) lock everything but a given region (i.e. make parts outside of this region non-editable).


Solution

  • You might try the Eclipse folding plugin at:

    http://kosiara87.blogspot.com/2011/12/how-to-install-coffee-bytes-plugin-in.html

    With a download at:

    http://sites.google.com/site/bkosarzyckistorage1/eclipse-folding-plugin.tar.gz

    It lets you define identifiers for start and end region, and then put them in your document to control visibility by region (apparently line based, rather than finer-grained, but that what most people tend to want).

    In the "User Defined Regions" tab use e.g.:

    Start identifier: region    End identifier: endregion
    

    In code:

    //region SomeName
    your code
    //endregion SomeName
    

    There's a thread on this in What code folding plugins work on Eclipse 3.6?

    I haven't used it myself but it might fit your needs. It might also be incompatible with current versions of Eclipse - the page describing it is from about a year and a half ago.