In VIM, a VIM plugin has to be made to create a user interface which contains the menus of RefactorErl as well as those commands with the help of which the refactorings can be run and the files loaded in the system can be handled.
Installation
To install the plugin, you can copy it to the vim ftplugin directory. The plugin is located in REFACTORERL/lib/referl_ui/vim/ftplugin directory and consists of 2 files: referl.py and referl.vim. For the plugin you also need python 2. You can download it from http://www.python.org. For global installation, the ftplugin directory is usually located in /usr/share/vim/vimVersion/ftplugin, for local install copy the plugin to HOME/.vim/ftplugin directory.
Next, you should modify the refpath variable in the referl.vim script to the installation directory of RefactorErl. You should also set the other variables shown in the table.
Variable name | Value |
refpath | you must enter the full path to the RefactorErl executable under the directory of the tool (under bin directory). |
ref_base_path | you must enter the full path to the root directory of the tool. |
ref_undo_mode | selective_undo or one_step |
ref_datadir | path to directory of data used by RefactorErl |
ref_name_type | sname or name |
ref_server_name | name of the server node |
ref_db_type | here you can choose the database type RefactorErl uses. |
If you want to use the plugin only as filetype plugin then you should copy the files instead of plugin under ftplugin, and also add the following lines to your .vimrc. (The .vimrc is located under HOME.)
au BufNewFile,BufRead *.hrl source path/to/referl.vim au BufNewFile,BufRead *.erl source path/to/referl.vim
Since VIM interface is based on CLI it should be properly configured. For proper configuration of CLI, see the corresponding section CommandLineInterface.
The VIM interface also supports an undo function, which has to modes: one step mode and selective undo mode. In the VIM script you have to set the ref_undo_mode variable. If you choose selective undo mode, you need an additional software component. For details about install and the usage of the undo function see page EmacsInterface/Undo.
For details about the undo function see page EmacsInterface/Undo.
Since the VIM interface does not cover all features of the tool, it is a good idea to use another interface, e.g. the Erlang shell interface (ri).
Menu and command structure
VIM can be used both in command line and in graphical environment. The VIM plugin of RefactorErl supports both of them. In the graphical front-end every command can be reached from the RefactorErl menu. The features are grouped to be easily found. These groups and the most important tasks can be found in the following, and the second column of the table shows the corresponding command to be used in non-graphical mode.
Menu item | Command |
Server | --- |
Files | --- |
Undo (One step only) | Refundo |
Undo | Refundo |
Redo | Refredo |
Semantic query | Refsq |
Function | --- |
Introduce/Eliminate? | --- |
Move to another module | --- |
Renaming | --- |
Upgrade | --- |
Help | Refh |
Server submenu
The server can be started and stopped by the menus and commands shown in the following table. If the RefactorErl cannot be started an error message is shown in command buffer.
Menu item | Command |
Server | --- |
-> Start | RefSta |
-> Stop | RefSto |
Files submenu
Features dealing with files can be found in the following tables. Draw graph makes a graphical representation of the database by creating a dot file.
Menu item | Command |
Files | --- |
-> Add file | Refa |
-> Drop file | Refd |
-> Show database | Refls |
-> Draw Graph | Refgraph |
Function submenu
This submenu contains only the Reorder function parameter refactoring, this menu group has been created for future use.
Menu item | Command |
Function | --- |
-> Reorder function parameter | Refof |
Introduce/Eliminate? submenu
In this submenu the refactorings concerning introduction and elimination of certain language constructs can be found.
Menu item | Command |
Introduce/Eliminate? | --- |
-> Eliminate function call | Refef |
-> Eliminate macro substitution | Refem |
-> Eliminate variable | Refev |
-> Eliminate fun expression | Refeu |
-> Introduce function | Refif |
-> Introduce import | Refii |
-> Introduce record | Refir |
-> Introduce variable | Refiv |
-> Introduce process | Reffp |
-> Introduce function argument | Refia |
-> Introduce tuple | Reftf |
-> Transform list comprehension | Reftl |
Move to another module submenu
In this menu item the refactorings concerning moving can be found. The modules changed by the refactoring are not opened.
Menu item | Command |
Move to another module | --- |
-> Move function | Refmf |
-> Move macro | Refmm |
-> Move record | Refmr |
Upgrade submenu
The upgrade regexp refactoring can be found in the Upgrade submenu. This menu has been created for future use, too.
Menu item | Command |
Upgrade | --- |
-> Upgrade regexp interface | Refuir |
Renaming submenu
The universal renamer and the type specific renamer refactorings can be found in this submenu.
Menu item | Command |
Renaming | --- |
-> Universal renamer | Refr |
-> Rename function | Refrf |
-> Rename header | Refrh |
-> Rename macro | Refrc |
-> Rename module | Refrm |
-> Rename record | Refrrd |
-> Rename record field | Refrrf |
-> Rename variable | Refrv |
Position based refactorings
Refactorings need either a single position or a range as a subject. In VIM, a range can be selected only in Visual mode, but you cannot execute a single statement while Visual mode is active, so you have to save the boundaries of the selection by pressing F2. Then you can run the range based refactorings. Position based refactorings are not affected by any saved ranges, they determine the actual cursor position every time a refactoring is started.
Interaction
If any of the given argument is missing or incorrect the interface provides user interaction to collect required data. To cancel an ongoing interaction you should use a blank answer.
Semantic queries
Semantic queries are fully supported in VIM interface. VIM does not support links to different sources, but the path and the location are listed after all entity in the result. This filepath can be copied and pasted after an open command (:e +line filepath ).
Attachments (2)
-
gvim.png
(72.7 KB) -
added by manualwiki 13 years ago.
GVim interface
-
gvim-undo.png
(66.5 KB) -
added by manualwiki 12 years ago.
GVim undo
Download all attachments as: .zip