Last active
March 13, 2016 18:55
-
-
Save stefanschmidt/ac825c6d65a8a11f3446 to your computer and use it in GitHub Desktop.
Switch orientation of guillemets in Textmate from outwards to inwards (or vice-versa)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# user preferences for the builtin text bundle | |
PREF_FILE="$HOME/Library/Application Support/Avian/Bundles/Text.tmbundle/Preferences/Miscellaneous.tmPreferences" | |
# single and double guillemets in both directions | |
SINGLE_LEFT="<string>‹<\/string>"; SINGLE_RIGHT="<string>›<\/string>" | |
DOUBLE_LEFT="<string>«<\/string>"; DOUBLE_RIGHT="<string>»<\/string>" | |
# perl syntax used below | |
# -i: inplace editing | |
# -p: iterate over files | |
# -e: execute command | |
# -0: read file at once | |
# s/: substitute a string | |
# /s: multiline matching | |
# /g: substitute all occurences | |
# switch guillemets from outwards-facing («...») to inwards-facing (»...«) | |
perl -0pi -e "s/$SINGLE_LEFT(\s*)$SINGLE_RIGHT/$SINGLE_RIGHT\1$SINGLE_LEFT/sg" "$PREF_FILE" | |
perl -0pi -e "s/$DOUBLE_LEFT(\s*)$DOUBLE_RIGHT/$DOUBLE_RIGHT\1$DOUBLE_LEFT/sg" "$PREF_FILE" | |
# switch guillemets from inwards-facing (»...«) to outwards-facing («...») | |
perl -0pi -e "s/$SINGLE_RIGHT(\s*)$SINGLE_LEFT/$SINGLE_LEFT\1$SINGLE_RIGHT/sg" "$PREF_FILE" | |
perl -0pi -e "s/$DOUBLE_RIGHT(\s*)$DOUBLE_LEFT/$DOUBLE_LEFT\1$DOUBLE_RIGHT/sg" "$PREF_FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment