Pycharm 重构-重命名函数内部 [英] Pycharm refactoring-renaming inside function

查看:69
本文介绍了Pycharm 重构-重命名函数内部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Pycharm 中,可以使用 (shift + F6) 键轻松地重命名项目范围内的变量以重构重命名变量

In Pycharm one can easily rename a variable project wide using the (shift + F6) key to refactor-rename a variable

但是在函数内部无法做到这一点.

But it is unable to do this inside a function.

一种解决方法是使用搜索替换,但由于我已经习惯了重构重命名,我想找到一种方法来在函数内部重构重命名.

A workaround would be to use search-replace, But as I've gotten used to refactor-renaming i would like to find a way to refactor-rename inside a function.

感谢阅读

推荐答案

PyCharm 认识到变量的有限范围(在函数内部),并且在这种情况下重构的行为略有不同 - 通常的重构对话不再打开.

PyCharm recognizes the limited scope of the variable (inside the function) and refactoring behaves slightly different in this case - the usual refactoring dialogue no longer opens up.

>

函数内所有变量实例的绿色背景(在您的示例中,实际颜色可能因配色方案和自定义而异)表明 pycharm 处于这种本地重构模式.只需编辑变量名称,您就会看到所有变量实例同时被修改.完成后按Enter,绿色背景消失,表示本地重构模式结束.

The green background (in your example, the actual colour may differ depending on the color scheme and customisations) for all the variable's instances inside the function indicates pycharm is in this local refactoring mode. Just edit the variable name and you'll see all the variable instances being modified simultaneously. Press Enter when done and the green background disappears indicating that the local refactoring mode ended.

这篇关于Pycharm 重构-重命名函数内部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆