-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatic insertion of Unicode characters from typing shortcuts (a.k.a. autocorrect) #13856
Comments
Cf. #12043 The HTML Tag plugin may someday have the capability of decoding Unicode escapes as you type. In the meantime, you can use PythonScript. |
The PythonScript that @rdipardo linked to doesn't really do what @rkj90266 wants. A better script for the desired situation is one that installs a CHARADDED callback. The callback logic would check the characters entered previously and look for the Such a script might be this one, suggested name:
|
May I also ask ... is there an easy addition to the script that would turn the callback on and off? So I could enable it or disable it as needed? I can presently turn it off by restarting np++, kinda inconvenient. |
I'm glad you like it.
Why would you want to turn it off? Are there circumstances where you would type But regardless, what follows is a slightly modified version of the script that, every time it is run, toggles the state of whether substitutions are made ("on") or not ("off"). PythonScript has some history with callbacks not always being uninstalled correctly, so what is done here is that the callback is left installed, but its logic isn't executed if the current state is "off".
|
Yup, this sure looks a little smoother than the solutions we had in my thread, and definitely better than switching text windows to find the symbol for copy-paste. When building the script, are you just copy-pasting the characters into it, or would you need to use the unicode or other strings ? |
When writing the demo script, I just went to Windows' charmap program and changed to the Greek section and copied out a couple of characters. I think that's what you're asking; if not, I don't know what you're asking. |
@rkreilly I went to "Insert Symbol" in MS Word. I also have an "autocorrect.doc" document that contains all the definitions and a VBA macro to install them for MS Office so I copied those to put into the Python dictionary. Here's my list in case it's of any use to you: |
I'm a newbie with PythonScript but I tried this as written and it's not working as expected. I think I need to name the script "DynamicReplaceAsType.py", which I did. When I open npp it's not activated. When I run the script the first time it's still not activated. When I run it a second time it is then activated, and can be toggled by subsequent runs. |
It can be named whatever you like, but what you've chosen is a good name. :-)
Correct. To have it autoactivated, you'd have to follow the instructions after
Hmm, not my experience; just tried again on a fresh setup. Not sure what is going wrong for you.
Perhaps something in the "notes for newbies" will help? See https://community.notepad-plus-plus.org/topic/23039/faq-desk-how-to-install-and-run-a-script-in-pythonscript |
Thanks for the "newbie: link. I found there the dropdown for Python initialization and changed it from "LAZY" to "ATSTARTUP" and now it's activated when I start npp. Thanks again for sharing this. |
Ah, yes, that being set to LAZY would jibe with your earlier experience. |
Description of the Issue
This is a feature request. In Microsoft apps there is an "autocorrect" feature that automatically replaces strings with replacement strings based on the contents of a replacement table. Microsoft uses it for spelling correction as you type but I use it for non-ASCII character insertion, for example all the Greek letters can be inserted by typing \alpha .. \omega, and upper case with \Alpha .. \Omega. Also available are the \degrees symbol, math operators \pm, \ge, \le. These shortcuts are generally the same as those available when typesetting math in TeX or LaTeX. I programmed all these shortcuts myself and they are very handy and easy to remember.
So basically I'm wishing that a regular feature or plugin was available to do this in npp.
Steps to Reproduce the Issue
N/A
Expected Behavior
When you type "\beta", the string "\beta" is automatically replaced by the Greek letter beta (Unicode character 03B2). Strings to be replaced to be defined in a suitable user-editable table.
Actual Behavior
I went to MS Word to get the character and pasted it into npp.
Debug Information
N/A
N/A
The text was updated successfully, but these errors were encountered: