sponsor Vim development Vim logo Vim Book Ad

factorus : Vim plugin for automated refactoring

 script karma  Rating 34/12, Downloaded by 2525  Comments, bugs, improvements  Vim wiki

created by
Austin Palmer
script type
Git repo:  https://github.com/apalmer1377/factorus.git

Factorus is a Vim plugin for automated refactoring. It provides many of the refactoring features found in IDEs like Eclipse or IntelliJ, without sacrificing the lightness of Vim.

Currently, Factorus supports automated versions of the following refactoring tools for the following languages:

Add Parameter--Java, Python, C, C++
Encapsulate Variable--Java
Extract Method (automated)--Java, Python, C, C++
Extract Method (manual)--Java, Python, C, C++
Rename Argument--Java, Python, C, C++
Rename Class--Java, Python
Rename Method--Java, Python, C, C++
Rename Field--Java, C, C++
Rename Type--C, C++
Rename Macro--C, C++

NOTE: C++ functionality is limited, and may not work with more complex code bases.

Factorus also has commands for reverting changes and rebuilding projects, for stability and sanity testing.
install details
To install Factorus, you can:

- Use a plugin manager like pathogen or vim-plug,
- Clone the git repository into your 'runtimepath',  or
- Download the tar file and extract it into a directory in your 'runtimepath'.

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
factorus.tar 2.0 2019-09-19 7.0 Austin Palmer Limited C++ functionality has been added; it works the exact same as the C functionality, so it can fail with more complex C++ code. Improvements were also made to extractMethod across the board.
factorus.tar 1.984375 2017-07-31 7.0 Austin Palmer GENERAL:

- strange "find" error occasionally with large codebases or frequent use of system('find')
- A lot of issues with extractMethod (frequently extracts invalid code snippets, lines from mismatched blocks, etc.)

- Manual extraction (methods, types, etc.)
- Add default argument to function with added parameter
- Add examples to README (prelim 2017-07-26)
- Improve FRebuild output
- look in project root directory for build file before searching (DONE 2017-07-27)


- getSubClasses sometimes causes unwanted tabs to stay open, and wanted tabs to close
- getSubClasses not always getting correct class (nested class implements superclasses, but gets marked as outer level instead of inner level)

- Add optional 'name' parameter for FEncapsulate


- Typedefs not noticed in renameField
- Structs defined within structs not properly identified in renameField
- Arrays of structs not identified in renameField
- Method declarations without implementation not noticed as tags
- Struct definition with no name shouldn't be noticed as a tag
- renameType doesn't search all header files (header files don't need to include base file)
- rollbackRename sometimes throws 'unable to open swap file' error
- rename needs to update include files in case of static
factorus.tar 1.96875 2017-07-24 7.0 Austin Palmer C SUPPORT--RELEASE 1.96875


- Added support for C programming language (addParam, renameArg, renameType, renameMethod, extractMethod, renameMacro, renameField)

- Rollback for renameClass doesn't work properly (FIXED 2017-07-17)
- updateQuickFix breaks if only one file is read (FIXED 2017-07-17)


- single-line, no-bracket for and while loops screw with getAllBlocks (FIXED 2017-07-17 for while, for is tricker)

- add ability to rename enum field (i.e., if you have enum DayOfWeek, rename Monday to MONDAY) (DONE 2017-07-17)
factorus.tar 1.9375 2017-07-13 7.0 Austin Palmer =======

Bug Fixes
- FRollback doesn't work properly if quickfix file gets opened (FIXED 07-11-2017)

New Features/Improvements
- Rebuild command to validate code changes (ant/gradle/make/maven builds)
- Make all methods atomic--if an error is thrown or the function is interrupted, roll back the changes
- Provide list of all files/ all changes made after a rename
- Provide list of all changes NOT made after a rename
- Allow both changes and unchanges to be seen (I know that isn't a word)


Bug Fixes
- When breaking up lines in extractMethod, function hangs when line length == g:factorus_line_length
- When other declarations were before return declaration, extractMethod incorrectly added declaration into conditional block
- End message doesn't display when running FRollback from other tab
- Multiple declarations on the same line (int i,j) don't get noticed
- When constructed type contains question mark (Foo<? extends Bar>), declarations don't get noticed
- extractMethod still sometimes not noticing conditionals
- When subclass declaration extends multiple lines, subclass doesn't get noticed
- Classes with the same name in the same package should be considered the same entity

New Features/Improvements
- Speed up renameMethod (again)


Bug Fixes
- Some changes can't be seen in rename, and so are overwritten

New Features/Improvements
- Rollback function--when things don't go as expected, provide a rollback to undo the previous action
- extractMethod function
factorus.tar 1.875 2017-07-07 7.0 Austin Palmer JAVA BUG FIXES:
- When two references to a method occur on the same line, only the first gets updated (FIXED)
- Methods of superclasses don't get checked in updateOutliers (FIXED)
- Methods returning Collections or other structures(Trees, Lists, Sets) don't get updated (CLOSED 07-07-2017)
- getSuperClasses method causes strange "find: too many open files" error (FIXED)
- Methods that are the initiater of a chain don't get updated (CLOSED 07-07-2017)
- Methods with the 'synchronized' keyword aren't noticed (FIXED 07-06-2017)
- When renaming a method or field, we should find the base class in which it's declared (CLOSED 07-07-2017)
- When a class inherits from multiple other classes/interfaces, only the first is retrieved (FIXED 07-06-2017)
- When a reflected type inherits from something in a class definition (<T extends List>), the reflected type is considered a superclass (FIXED 07-06-2017)
- Switch statements are not recognized as blocks in extractMethod (TESTING 07-07-2017)
- Increment and decrement operators not counted as left references (FIXED 07-07-2017)
- Slight formatting error in formatMethod (FIXED 07-07-2017)
- Methods with only one declared variable cause infinite loop (FIXED 07-07-2017)

- Rollback function--when things don't go as expected, provide a rollback to undo the previous action (DONE 07-06-2017)
- Speed up renameMethod

factorus.tar 1.75 2017-06-30 7.0 Austin Palmer *Added addParam, renameClass, renameMethod, and renameArg for Python* *Changed various regex bugs that caused failures in Java* *Improved method renaming algorithm in Java*
factorus.tar 1.5 2017-06-29 7.0 Austin Palmer patch for overlong regular expression
factorus.tar 1.0 2017-06-26 7.0 Austin Palmer Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.