Stop PyCharm autocomplete from rewrite code in front of my cursor

I use PyCharm to write python code and notice that I often encounter the following problem:

I am writing a line of code like this

for item in myList: 

Later, I understand that I need an item index, so I'm trying to turn this string into this:

 for i,item in enumerate(myList): 

To rotate the first line to the second, I placed the cursor to the left of item and typed i, Then I placed the cursor to the left of myList and typed enu ; by this time the code-add. suggests that I can type enumerate , which is exactly the behavior I use. When I pressed tab to implement the proposed enumerate , I noticed that my string turns into

 for i,item in enumerate: 

myList been overwritten!
The behavior I expect is as follows:

 for i,item in enumerate(myList): 

with the cursor immediately to the right of myList or :

Is there any way to get Pycharm to behave according to my expectations?

Just in case it matters, my environment for developers is Mac OSX 10.7.5 (Lion)

+6
source share
2 answers

This design behavior is at the end of using Tab . Use Enter instead of a tab to insert a completion option instead of overwriting.

The code completion settings dialog box also has the ability to insert an option by typing a period, space, etc.

+6
source

This is the default behavior in PyCharm, if you press TAB when connecting to another word like en|myList , then myList will be deleted.

What you can do is double-click myList , press CRTL + ALT + T , press ENTER , and then press <- . Then just enter enumerate .

If you do this regularly, you can simply create a lively template that surrounds.

+1
source

Source: https://habr.com/ru/post/956277/


All Articles