python-rope / ropevim

vim mode that uses rope library to provide features like python refactorings and code-assists
GNU General Public License v2.0
245 stars 34 forks source link

Missing 'range' in function definition #3

Closed mcepl closed 9 years ago

mcepl commented 10 years ago

Hi,

I thing that at least for vim 7.3 you need to add "range" when creating function at this line: https://bitbucket.org/agr/ropevim/src/4bd40366d3aee3447b6baeb069f345d61e793f97/ropevim.py?at=default#cl-272

It should look like:

#!python

    def _add_function(self, name, callback, prefix=False):
        globals()[name] = callback
        arg = 'None' if prefix else ''
        vim.command('function! %s() range\n' % _vim_name(name) +
                    'python ropevim.%s(%s)\n' % (name, arg) +
                    'endfunction\n')

Without that when for example you select several lines and use key combination C-c r m (ExtractMethod) then it will be run for every line.