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

Not able to mark region to refactor #64

Closed vcrini closed 2 years ago

vcrini commented 7 years ago

Hi, I'm trying to select a region of code for refactoring.

E.g. Say want to RopeExtractVariable from this piece of code (that's trivial I know but it shows my problem)

before refactoring

print(1+2+3)

to

sum=1+2+3
print(sum)

How can I tell vim to select "1+2+3" region?

I'm trying by selecting in visual code but I'm failing with error

RefactoringError: Extracted piece should contain complete statements.

If answer is trivial please can you direct me to resource explaining this? Thanks a lot, Valerio

lieryan commented 5 years ago

This is a bit tricky, but I think there is an off by one bug on the end marker for inline refactoring, you'd actually have to select the next character for inline refactoring to detect the selected text correctly.

So if your text is:

print(1+2+3)
      ------

your cursor needs to be selecting the underlined characters.