Import it into iOS TextExpander using the Add via URL option.Upload the changed file to a publicly accessible server and get its URL.textexpander file.Ĭhange the prefix through a command like reaffix -old-prefix=' ' -new-prefix='zz' -r Symbols.textexpander On iOS I use the same “base” abbreviations, but with a “zz” prefix.īecause my snippets have this difference between platforms, I can’t use TextExpander’s various syncing mechanisms. But it stinks as a prefix on the iPhone because the semicolon isn’t on the main keyboard. I chose the semicolon prefix long before there was such a thing as TextExpander and I’m loath to change it because it’s part of my muscle memory. Lines 57–70 then walk through the dictionary and change the abbreviations according to the directions given on the command line.įor me, an important use of reaffix is to make my snippets easier to use on my iPhone. There is, frankly, no need for Lines 27–32, but I prefer using variables with short names later in the program.Īfter some filename fiddling, plistlib reads the snippet library file in Line 50 and parses it into the dictionary te. Lines 8–23 define the usage message, which docopt parses into the args dictionary in Line 26. All the other modules are already on your Mac. It uses the docopt module, which you’ll have to install if you want to use reaffix yourself. textexpander file.ħ6: print "Couldn't write new textexpander file", outfile New affixes are added to all the abbreviations.'''ģ5: basename, extension = os.path.splitext(infile)ģ7: # Make sure it's a TextExpander file.ģ9: print("%s is not a TextExpander file." % infile)Ĥ6: outfile = basename + "-2" + extensionĥ5: # Go through the snippets, changing affixes for each abbreviation.ĥ6: # Skip snippets that have an empty abbreviation.ĥ7: for i, a in enumerate(te):Ħ2: if oldP is not None and a.startswith(oldP):Ħ4: if oldS is not None and a.endswith(oldS):ħ0: te = newabbrevħ2: # Write out the new. Old affixes are stripped from all the abbreviations that haveĢ3: them. Here’s the source code for reaffix: python:Ĩ: usage = '''Usage: reaffix TEFILEġ0: Change the abbreviation prefix or suffix in a TextExpander plist file.ġ7: -replace, -r write over the original file instead ofĢ1: Normally, there should be at least one "old" and one "new" optionĢ2: given. This particular example would rewrite the Markdown.textexpander library to have abbreviations that start with semicolons instead of double commas. I call it reaffix, and I typically use it this way: reaffix -r -old-prefix=',' -new-prefix=' ' Markdown.textexpander I used it to make a little script for changing the prefixes (and suffixes, if that’s what you’re into) of snippets in a TextExpander library. Luckily for me, the Python Standard Library includes the plistlib module, which has several methods for reading, parsing, and writing plist files. textexpander extension, are how snippets are shared on sites like the TextExpander Google+ page. You create snippet libraries by chosing Save a Copy of Group… from TextExpander’s little gear menu. One answer comes from the recognition that TextExpander snippet libraries are just plist files, the common format for OS X configuration settings. I say “someone like Brett” because Brett himself offers his snippets through a web page that lets you define your own prefix. If I want to import a set of snippets shared by someone like Brett, how do I change the abbreviations to match my prefix without going through the set and editing them one by one? Brett Terpstra, for example, uses a pair of commas as the prefix for his snippet abbreviations. Lots of TextExpander users design their abbreviations this way, but they don’t always use a semicolon. Even when programming in a language that uses semicolons as statement delimiters, I never squeeze the next statement up against the semicolon that ends the previous one. I chose the semicolon because it’s on the home row of keys and I never type a semicolon without putting a space or newline between it and the following text. In my early days with TextExpander, I fiddled with the delimiter set, but inevitably got either expansion when I didn’t want it or no expansion when I did.Īfter switching to this setting, I found that the only way to get snippet abbreviations that were both memorable and not actual words was to start each abbreviation with a character that’d never be part of a word. Like all right-thinking TextExpander users, I have the expansion preference set to “immediately when typed” because I’ve never found a set of delimiter characters that always works. Next post Previous post Fixing TextExpander prefixes
0 Comments
Leave a Reply. |