|
| 1 | +*ropevim.txt* |
| 2 | + |
| 3 | +Refactoring Dialog |
| 4 | +------------------ |
| 5 | + |
| 6 | +Ropevim refactorings use a special kind of dialog. Depending on the |
| 7 | +refactoring, you'll be asked about the essential information a |
| 8 | +refactoring needs to know (like the new name in rename refactoring). |
| 9 | + |
| 10 | +Next you'll see the base prompt of a refactoring dialog that shows |
| 11 | +something like "Choose what to do". By entering the name of a |
| 12 | +refactoring option you can set its value. After setting each option |
| 13 | +you'll be returned back to the base prompt. Finally, you can ask rope |
| 14 | +to perform, preview or cancel the refactoring. |
| 15 | + |
| 16 | +See keybinding_ section and try the refactorings yourself. |
| 17 | + |
| 18 | + |
| 19 | +Finding Files |
| 20 | +------------- |
| 21 | + |
| 22 | +By using ``RopeFindFile`` (``C-x p f`` by default), you can search for |
| 23 | +files in your project. When you complete the minibuffer you'll see |
| 24 | +all files in the project; files are shown as their reversed paths. |
| 25 | +For instance ``projectroot/docs/todo.txt`` is shown like |
| 26 | +``todo.txt<docs``. This way you can find files faster in your |
| 27 | +project. ``RopeFindFileOtherWindow`` (``C-x p 4 f``) opens the |
| 28 | +file in the other window. |
| 29 | + |
| 30 | + |
| 31 | +============================================================================== |
| 32 | +Code-Assist *rope_codeassist* |
| 33 | +----------- |
| 34 | + |
| 35 | +``RopeCodeAssist`` command (``M-/``) will let you select from a list |
| 36 | +of completions. ``RopeLuckyAssist`` command (``M-?``) does not ask |
| 37 | +anything; instead, it inserts the first proposal. |
| 38 | + |
| 39 | +You can tell ropevim to use vim's complete function in insert mode; |
| 40 | +Add:: |
| 41 | + |
| 42 | + let ropevim_vim_completion=1 |
| 43 | + |
| 44 | +to your ``~/.vimrc`` file. |
| 45 | + |
| 46 | +Note that when this variable is set, autoimport completions no longer |
| 47 | +work since they need to insert an import to the top of the module, too. |
| 48 | + |
| 49 | +By default autocomplete feature will use plain list of proposed completion |
| 50 | +items. You can enable showing extended information about completion |
| 51 | +proposals by setting :: |
| 52 | + |
| 53 | + let ropevim_extended_complete=1 |
| 54 | + |
| 55 | +Completion menu list will show the proposed name itself, one letter which |
| 56 | +shows where this proposal came from (it can be "L" for locals, "G" for |
| 57 | +globals, "B" for builtins, or empty string if such scope definition is not |
| 58 | +applicable), a short object type description (such as "func", "param", |
| 59 | +"meth" and so forth) and a first line of proposed object's docstring (if it |
| 60 | +has one). For function's keyword parameters the last field shows "*" symbol |
| 61 | +if this param is required or "= <default value>" if it is not. |
| 62 | + |
| 63 | +Note that you'll need rope r1558:0d76aa9d0614 or later and ropemode |
| 64 | +r35:bd77ca42b04d or later for extended complete feature to work. |
| 65 | + |
| 66 | + |
| 67 | +============================================================================== |
| 68 | +Enabling Autoimport *rope_autoimport* |
| 69 | +------------------- |
| 70 | + |
| 71 | +Rope can propose and automatically import global names in other |
| 72 | +modules. Rope maintains a cache of global names for each project. It |
| 73 | +updates the cache only when modules are changed; if you want to cache |
| 74 | +all your modules at once, use ``RopeGenerateAutoimportCache``. It |
| 75 | +will cache all of the modules inside the project plus those whose |
| 76 | +names are listed in ``ropevim_autoimport_modules`` list:: |
| 77 | + |
| 78 | + # add the name of modules you want to autoimport |
| 79 | + let g:ropevim_autoimport_modules = ["os", "shutil"] |
| 80 | + |
| 81 | +Now if you are in a buffer that contains:: |
| 82 | + |
| 83 | + rmtree |
| 84 | + |
| 85 | +and you execute ``RopevimAutoImport`` you'll end up with:: |
| 86 | + |
| 87 | + from shutil import rmtree |
| 88 | + rmtree |
| 89 | + |
| 90 | +Also ``RopeCodeAssist`` and ``RopeLuckyAssist`` propose auto-imported |
| 91 | +names by using ``name : module`` style. Selecting them will import |
| 92 | +the module automatically. |
| 93 | + |
| 94 | + |
| 95 | +Filtering Resources |
| 96 | +------------------- |
| 97 | + |
| 98 | +Some refactorings, restructuring and find occurrences take an option |
| 99 | +called resources. This option can be used to limit the resources on |
| 100 | +which a refactoring should be applied. |
| 101 | + |
| 102 | +It uses a simple format: each line starts with either '+' or '-'. |
| 103 | +Each '+' means include the file (or its children if it's a folder) |
| 104 | +that comes after it. '-' has the same meaning for exclusion. So |
| 105 | +using:: |
| 106 | + |
| 107 | + +rope |
| 108 | + +ropetest |
| 109 | + -rope/contrib |
| 110 | + |
| 111 | +means include all python files inside ``rope`` and ``ropetest`` |
| 112 | +folders and their subfolder, but those that are in ``rope/contrib``. |
| 113 | +Or:: |
| 114 | + |
| 115 | + -ropetest |
| 116 | + -setup.py |
| 117 | + |
| 118 | +means include all python files inside the project but ``setup.py`` and |
| 119 | +those under ``ropetest`` folder. |
| 120 | + |
| 121 | + |
| 122 | +Finding Occurrences |
| 123 | +------------------- |
| 124 | + |
| 125 | +The find occurrences command (``C-c f`` by default) can be used to |
| 126 | +find the occurrences of a python name. If ``unsure`` option is |
| 127 | +``yes``, it will also show unsure occurrences; unsure occurrences are |
| 128 | +indicated with a ``?`` mark in the end. Note that ropevim uses the |
| 129 | +quickfix feature of vim for marking occurrence locations. |
| 130 | + |
| 131 | + |
| 132 | +Dialog ``batchset`` Command |
| 133 | +--------------------------- |
| 134 | + |
| 135 | +When you use ropevim dialogs there is a command called ``batchset``. |
| 136 | +It can set many options at the same time. After selecting this |
| 137 | +command from dialog base prompt, you are asked to enter a string. |
| 138 | + |
| 139 | +``batchset`` strings can set the value of configs in two ways. The |
| 140 | +single line form is like this:: |
| 141 | + |
| 142 | + name1 value1 |
| 143 | + name2 value2 |
| 144 | + |
| 145 | +That is the name of config is followed its value. For multi-line |
| 146 | +values you can use:: |
| 147 | + |
| 148 | + name1 |
| 149 | + line1 |
| 150 | + line2 |
| 151 | + |
| 152 | + name2 |
| 153 | + line3 |
| 154 | + |
| 155 | +Each line of the definition should start with a space or a tab. Note |
| 156 | +that blank lines before the name of config definitions are ignored. |
| 157 | + |
| 158 | +``batchset`` command is useful when performing refactorings with long |
| 159 | +configs, like restructurings:: |
| 160 | + |
| 161 | + pattern ${pycore}.create_module(${project}.root, ${name}) |
| 162 | + |
| 163 | + goal generate.create_module(${project}, ${name}) |
| 164 | + |
| 165 | + imports |
| 166 | + from rope.contrib import generate |
| 167 | + |
| 168 | + args |
| 169 | + pycore: type=rope.base.pycore.PyCore |
| 170 | + project: type=rope.base.project.Project |
| 171 | + |
| 172 | +.. ignore the two-space indents |
| 173 | + |
| 174 | +This is a valid ``batchset`` string for restructurings. |
| 175 | + |
| 176 | +Just for the sake of completeness, the reverse of the above |
| 177 | +restructuring can be:: |
| 178 | + |
| 179 | + pattern ${create_module}(${project}, ${name}) |
| 180 | + |
| 181 | + goal ${project}.pycore.create_module(${project}.root, ${name}) |
| 182 | + |
| 183 | + args |
| 184 | + create_module: name=rope.contrib.generate.create_module |
| 185 | + project: type=rope.base.project.Project |
| 186 | + |
| 187 | + |
| 188 | +============================================================================== |
| 189 | +Variables *rope_variables* |
| 190 | +========= |
| 191 | + |
| 192 | +* ``ropevim_codeassist_maxfixes``: The maximum number of syntax errors |
| 193 | + to fix for code assists. The default value is ``1``. |
| 194 | +* ``ropevim_local_prefix``: The prefix for ropevim refactorings. |
| 195 | + Defaults to ``C-c r``. |
| 196 | +* ``ropevim_global_prefix``: The prefix for ropevim project commands |
| 197 | + Defaults to ``C-x p``. |
| 198 | +* ``ropevim_enable_shortcuts``: Shows whether to bind ropevim |
| 199 | + shortcuts keys. Defaults to ``1``. |
| 200 | +* ``ropevim_guess_project``: If non-zero, ropevim tries to guess and |
| 201 | + open the project that contains the file on which a ropevim command |
| 202 | + is performed when no project is already open. |
| 203 | + |
| 204 | +* ``ropevim_enable_autoimport``: Shows whether to enable autoimport. |
| 205 | +* ``ropevim_autoimport_modules``: The name of modules whose global |
| 206 | + names should be cached. `RopeGenerateAutoimportCache' reads this |
| 207 | + list and fills its cache. |
| 208 | +* ``ropevim_autoimport_underlineds``: If set, autoimport will cache |
| 209 | + names starting with underlines, too. |
| 210 | + |
| 211 | +* ``ropevim_goto_def_newwin``: If set, ropevim will open a new buffer |
| 212 | + for "go to definition" result if the definition found is located |
| 213 | + in another file. By default the file is open in the same buffer. |
| 214 | + |
| 215 | + |
| 216 | +============================================================================== |
| 217 | +Keybinding *rope_keys* |
| 218 | +========== |
| 219 | + |
| 220 | +Uses almost the same keybinding as ropemacs. Note that global |
| 221 | +commands have a ``C-x p`` prefix and local commands have a ``C-c r`` |
| 222 | +prefix. You can change that (see variables_ section). |
| 223 | + |
| 224 | +================ ============================ |
| 225 | +Key Command |
| 226 | +================ ============================ |
| 227 | +C-x p o RopeOpenProject |
| 228 | +C-x p k RopeCloseProject |
| 229 | +C-x p f RopeFindFile |
| 230 | +C-x p 4 f RopeFindFileOtherWindow |
| 231 | +C-x p u RopeUndo |
| 232 | +C-x p r RopeRedo |
| 233 | +C-x p c RopeProjectConfig |
| 234 | +C-x p n [mpfd] RopeCreate(Module|Package|File|Directory) |
| 235 | + RopeWriteProject |
| 236 | + |
| 237 | +C-c r r RopeRename |
| 238 | +C-c r l RopeExtractVariable |
| 239 | +C-c r m RopeExtractMethod |
| 240 | +C-c r i RopeInline |
| 241 | +C-c r v RopeMove |
| 242 | +C-c r x RopeRestructure |
| 243 | +C-c r u RopeUseFunction |
| 244 | +C-c r f RopeIntroduceFactory |
| 245 | +C-c r s RopeChangeSignature |
| 246 | +C-c r 1 r RopeRenameCurrentModule |
| 247 | +C-c r 1 v RopeMoveCurrentModule |
| 248 | +C-c r 1 p RopeModuleToPackage |
| 249 | + |
| 250 | +C-c r o RopeOrganizeImports |
| 251 | +C-c r n [vfcmp] RopeGenerate(Variable|Function|Class|Module|Package) |
| 252 | + |
| 253 | +C-c r a / RopeCodeAssist |
| 254 | +C-c r a g RopeGotoDefinition |
| 255 | +C-c r a d RopeShowDoc |
| 256 | +C-c r a f RopeFindOccurrences |
| 257 | +C-c r a ? RopeLuckyAssist |
| 258 | +C-c r a j RopeJumpToGlobal |
| 259 | +C-c r a c RopeShowCalltip |
| 260 | + RopeAnalyzeModule |
| 261 | + |
| 262 | + RopeAutoImport |
| 263 | + RopeGenerateAutoimportCache |
| 264 | +=============== ============================ |
| 265 | + |
| 266 | + |
| 267 | +Shortcuts |
| 268 | +--------- |
| 269 | + |
| 270 | +Some commands are used very frequently; specially the commands in |
| 271 | +code-assist group. You can define your own shortcuts like this:: |
| 272 | + |
| 273 | + :map <C-c>g :call RopeGotoDefinition() |
| 274 | + |
| 275 | +Ropevim itself comes with a few shortcuts. These shortcuts will be |
| 276 | +used only when ``ropevim_enable_shortcuts`` is set. |
| 277 | + |
| 278 | +================ ============================ |
| 279 | +Key Command |
| 280 | +================ ============================ |
| 281 | +M-/ RopeCodeAssist |
| 282 | +M-? RopeLuckyAssist |
| 283 | +C-c g RopeGotoDefinition |
| 284 | +C-c d RopeShowDoc |
| 285 | +C-c f RopeFindOccurrences |
| 286 | +================ ============================ |
| 287 | + |
| 288 | + |
0 commit comments