I usually prefer using a text editor (like Notepad++ or WriteMonkey) for my writing, but recently I’ve started using Word occasionally because I find the autocorrect feature to be an advantage. I do have tinyspell for spelling errors in my text editors, but really miss the autocorrect of two initial capitals (a frequent problem of mine). :-(
Is there any such plugin for Notepad++? I couldn’t find one, nor could I find any other named plugin that would do the same thing. (I may have missed something.) Or are there any plans for including one? Or does someone know of any other program that would accomplish the same thing and that works well with Notepad++?
Thanks for any suggestions. :-)
If all you are concerned about is the 2 initial capitals thing, you can easily script a solution to that. Otherwise, it is tough to judge if what you fully mean by autocorrect is script-fixable, unless you elaborate with some examples of what you would expect it to do. I think spell-check is a different thing than autocorrect, except maybe for the commonest set of simple words…
The Alan’s suggestion is excellent. To get a detection of all the ambiguous cases, go to the Plugins > DSpellCheck > Settings… panel. Then, click on the Advanced tab and, in the Ignore Words section :
Starting with Capital Letteroption
Having not First Capital Letteroption
All Letters Capitaloption
So, if we consider, for instance, the text, below :
1 license 2 License 3 LIcense 4 LICense 5 LICEnse 5 LicEnse 6 LicENSE 7 LiCENSE 9 LICENSE
the DSpellCheck plugin should only mark, as soon as the word is written, the cases
7, of the word license, assuming you use the English (Great Britain) dictionary, of course !
Now, with a simple regex S/R, we could reduce the ambiguous cases to cases
5, only ! That is to say that this S/R searches any word with an initial upper letter, wrongly followed by some other upper letters.
The drawback is that this regex should be executed from time to time or, at least, before saving the file and is not an interactive process, at all :-((
Open the Replace dialog (
Ctrl + H)
Check the Wrap around option
Choose the Regular expression search mode
Type in the regex
(?-i)\b(\u)(\u+)(\l+)\b, in the Find what: zone
Type in the regex
\1\L\2\3, in the Replace with: zone
Click on the Replace All button
=> You get the modified text :
1 license 2 License 3 License 4 License 5 License 5 LicEnse 6 LicENSE 7 LiCENSE 9 LICENSE
This S/R does not work, unfortunately, if your text contains accentuated upper letters :-(
An other formulation of this regex is :
Note that, with that second form, you’ll need to click, exclusively, on the Replace All button !
Thanks to both of you for your replies!
Alan: Actually, I’d be happy with just an autocorrect for two initial capitals, since the spell-checker is sufficient for those purposes. I’m something of a novice, though, so your “you can easily script a solution” doesn’t “easily” apply to me. :-) How might I go about this?
guy: Thanks for all that information! Even the detection of the instances that I might otherwise miss will be a help. :-)
Well, @alan-kilborn, I don’t know if it is straightforward, but I came up with a little Pythonscript to solve the two initial capitals problem. It’s not Unicode-ready and may have other shortcomings but it seemed to work for me.
# (A)uto(C)orrect(2)(I)nitial(C)aps import time try: AC2IC__LastAddTime except NameError: AC2IC__LastAddTime = time.time() def AC2IC__CharacterAdded(args): char_added_code = args['ch'] global AC2IC__LastAddTime tt = time.time() if tt - AC2IC__LastAddTime < 0.75: # only correct if the capitals occur quickly together cp = editor.getCurrentPos() if cp - editor.wordStartPosition(cp, True) == 2: if char_added_code >= ord('A') and char_added_code <= ord('Z'): prev_char_code = editor.getCharAt(cp - 2) if prev_char_code >= ord('A') and prev_char_code <= ord('Z'): editor.beginUndoAction() # perform the correction (change 2nd capital to lowercase) editor.deleteRange(cp - 1, 1) editor.insertText(cp - 1, chr(char_added_code).lower()) editor.endUndoAction() editor.setSelectionStart(cp); editor.setSelectionEnd(cp) AC2IC__LastAddTime = tt editor.callback(AC2IC__CharacterAdded, [SCINTILLANOTIFICATION.CHARADDED])
Thanks!! I’ll give it a go when I get a chance. :-)