How do you use replace in Spyder?

喜你入骨 提交于 2019-12-04 15:26:43

问题


Well, you start with cursor on your text, Ctrl+H and type replacement. But surprisingly i was not able to found any shorcut for actual replace or replace all action, rather than tabbing 5(!) times or moving my hand for a mouse.

Straightforward enter does nothing, tabbing to replace button and entering replaces, but throws me into the editor. VisualStudio-like Alt+A does nothing.

Am i missing something in spyder shortcuts?


回答1:


The shortcut for replace is Ctrl + R.




回答2:


I have the same issue with Spyder, I don't know why this has not been implemented in the editor.

The work around I currently have for multiple replace is to :

  1. Copy the replacement term to the clipboard

  2. Search(Find/Replace) for the term to replace

  3. Use F3 to select the next term

  4. Use paste Ctrl+V to replace it

  5. Back to step [3] to find the next term

Hope this helps!

EDIT:

According to Spyder dev @carlos below. Since v3.2 This has now been implemented and you may just press and move to the next term.




回答3:


(Spyder developer here) Since Spyder 3.2 you will be able to press Enter in the replace field to replace the current selection and automatically move to the next one.




回答4:


Are you on MacOS? There is an issue on github suggesting that the CMD+H shortcut is assigned to "hide spyder". An update will bind CMD+R as a replacement. As this has just been merged, it will take a few days before a dmg is available for MacOS. In the meantime you can go to Preferences --> Keyboard shortcuts --> editor: replace text and change the shortcut binding.

Reference:

https://github.com/spyder-ide/spyder/issues/2914




回答5:


Why just not use Notepad++?

In spyder editor, select the entire code (Ctrl+A), copy it (Ctrl+C) and paste it (Ctrl+V) into Notepad++. Then hit Ctrl+F, click on the "Replace" tab/menu (or you can use Tab to navigate) on the window that opens, write the string/value you want to find/replace, write the string/value you want to replace with, hit replace (or replace all: Alt+A; it will replace in the entire code). Do it as many times as you want/need - depending on how many unique values/strings you want to replace in the code. At any stage you can do Ctrl+Z to undo some actions or move the code from spyder editor to Notepad++ again (if you need to). Finally, select all, copy and paste it in the spyder editor and you're done.

It would be nice if spyder had this functionality implemented since it'd speed up the process but until then you can use this workaround. That's what i do also.

Video on how to do it (not mine): https://www.youtube.com/watch?v=I6-7GBY0ZHY



来源:https://stackoverflow.com/questions/35662566/how-do-you-use-replace-in-spyder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!