如何仅更改 VScode 中函数中的所有出现?

How do i change all occurrences only in the function in VScode?

在 VSCode 中,我可以通过 select 修改单词并使用“更改所有出现次数”功能来更改单词的所有出现次数。

此功能将 select 文件中的所有匹配词。 有什么办法可以 select 只在一个函数中出现所有事件,而不是在整个文件中出现?

例如,更改 f1() 中出现的所有“some_variable”,而不更改 f2() 中出现的所有“some_variable”:

f1():
    some_variable = 'meow'
    print(some_variable)
    

f2():
    some_variable = 'bark'
    print(some_variable)

Select 您要搜索的代码部分并使用“在 Selection 中查找”
在 windows 中,您可以使用快捷键 Alt + L
Here is demo for your example