Ask Your Question
1

hotkey to swap backslashes with forward slashes?

asked 2022-09-05 16:33:48 -0500

frueter's avatar

Hi, I am bouncing between all major operating systems all the time and often need to copy/paste file paths into my code for testing. Windows' backslashes have always driven me up the all and I know I can just use raw strings to use them as-is in my python code. But I would much prefer to swap them for forward slashes instead. I can obviously seatch and replace but was wondering if this could be set up as a macro of sorts and tied to a hotkey?

Cheers, frank

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-09-06 08:06:34 -0500

You can write a script to do this -- take a look at remove_prompts_and_paste() in scripts/editor-extensions.py in Wing's installation directory. That's close to what you want. You can make your own scripts file in scripts/myscripts.py (or any *.py file name) in your Settings Directory (listed in WIng's About box), add your script there, and then do Edit > Reload All Scripts to make it available in Wing. Reload All Scripts is only needed if you added a script file; after that WIng auto reloads changed script files so you can edit, save, and immediately test. You can invoke that script from Edit > Command by Name or bind a key to it in the User Interface > Keyboard > Custom Key Bindings preference.

For more info on extending Wing with Python scripts, see https://wingware.com/doc/scripting/index

edit flag offensive delete link more

Comments

Perfect, thanks!

frueter's avatar frueter  ( 2022-09-07 02:51:12 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2022-09-05 16:33:48 -0500

Seen: 21 times

Last updated: Sep 07