Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Command line application to leverage PPIx::EditorTools

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 samples
Octocat-spinner-32 script
Octocat-spinner-32 share
Octocat-spinner-32 t
Octocat-spinner-32 xt
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .releaserc
Octocat-spinner-32 Build.PL
Octocat-spinner-32 Changes
Octocat-spinner-32 INSTALL
Octocat-spinner-32 MANIFEST
Octocat-spinner-32 MANIFEST.SKIP
Octocat-spinner-32 README
Octocat-spinner-32 TODO
    App::EditorTools - Command line tool for Perl code refactoring

    "App::EditorTools" provides the "editortools" command line program that
    enables programming editors (Vim, Emacs, etc.) to take advantage of some
    sophisticated Perl refactoring tools. The tools utilize PPI to analyze
    Perl code and make intelligent changes. As of this release,
    "editortools" is able to:

    *   Lexically Rename a Variable

    *   Introduce a Temporary Variable

    *   Rename the Package Based on the Path of the File

    More refactoring tools are expected to be added in the future.

    The Padre Perl editor team developed some very interesting PPI based
    refactoring tools for their editor. Working with the Padre team, those
    routines were abstracted into PPIx::EditorTools in order to make them
    available to alternative editors.

    The initial implementation was developed for Vim. Pat Regan contributed
    the emacs bindings. Other editor bindings are encouraged/welcome.

    The following lists the refactoring routines that are currently
    supported. Please see App::EditorTools::Vim or App::EditorTools::Emacs
    to learn how to install the bindings and the short cuts to use within
    your editor. The command line interface should only be needed to develop
    the editor bindings.

    Each command expects the Perl program being edited to be piped in via
    STDIN. The refactored code is output on STDOUT.

            editortools renamevariable -c col -l line -r newvar

        Renames the variable at column "col" and line "line" to "newvar".
        Unlike editors typical find and replace, this is aware of lexical
        scope and only renames those variables within same scope. For
        example, given:

            my $x = 'text';
            for my $x (1..3){
                print $x;
            print $x;

        The command "editortools renamevariable -c 3 -l 12 -r counter" will
        result in:

            my $x = 'text';
            for my $counter (1..3){
                print $counter;
            print $x;

            editortools introducetemporaryvariable -s line1,col1 -e line2,col2 -v varname

        Removes the expression between line1,col1 and line2,col2 and
        replaces it with the temporary variable "varname". For example,

            my $x = 1 + (10 / 12) + 15;
            my $y = 3 + (10 / 12) + 17;

        The command "editortools introducetemporaryvariable -s 1,13 -e 1,21
        -v foo" will yield:

            my $foo = (10 / 12);
            my $x = 1 + $foo + 15;
            my $y = 3 + $foo + 17;

            editortools renamepackagefrompath -f filename

        Change the "package" declaration in the current file to reflect
        "filename". Typically this is used when you want to rename a module.
        Move the module to a new location and pass the new filename to the
        "editortools" command. For example, if you are editing
        "lib/App/" the package declaration will be changed to
        "package App::EditorTools;". At the moment there must be a valid
        package declaration in the file for this to work.

        If the "filename" is a file that exists in the system, then
        "renamepackagefrompath" will attempt to resolve any symlinks. This
        allows us work on files under a symlink (ie, M@ -> lib/App/Model),
        but rename them correctly.

            editortools renamepackage -n Package::Name

        Change the "package" declaration in the current file to
        Package::Name. At the moment there must be a valid package
        declaration in the file for this to work.

    part-3.html>, PPIx::EditorTools, Padre

    Please report any bugs or suggestions at

    Mark Grimes, <>

    Bug fixes and contributions from:

    *   Shlomi Fish

    *   Pat Regan (emacs interface)

    Copyright (C) 2010 by Mark Grimes

    This library is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself, either Perl version 5.8.2 or, at
    your option, any later version of Perl 5 you may have available.

Something went wrong with that request. Please try again.