There is a popular demand with developers dealing with Persian text to fix some incorrect characters which is often caused by bad/old Persian keyboard layouts.
It is a time consuming find and replace operation, which would be great if recorded into separate macros.
But unfortunately SublimeText lacks the ability of recording find and replace operations in its macros.
These SublimeText macro files, use the insert_snippet
command instead, with some regular expression substitution, to replace the following incorrect Persian characters with their correct alternatives.
- Replace Arabic yeh and keh with Persian yeh and keh. (
ي
toی
andك
toک
) - Replace Arabic digits with Persian digits. (
٠١٢٣٤٥٦٧٨٩
to۰۱۲۳۴۵۶۷۸۹
) - Replace English digits with Persian digits. (
0123456789
to۰۱۲۳۴۵۶۷۸۹
)
- Download the macro files.
- In SublimeText's menu go to
Preferences
→Browse Packages...
- In the opened folder go to the
User
directory. - Move the downloaded files here.
- For using with shortcuts, from SublimeText's menu go to Preferences → Key Bindings - User.
- In the opened file, add the content from the following
OS-User.sublime-keymap
files in between the brackets. (Make sure to add the required comma, if you already have any key-bindings) - You could obviously change the shortcuts to your desire.
- Have the Persian text containing errors in front of you (either as a saved file or as an unsaved text).
- In SublimeText's menu go to
Tools
→Macros
→User
→ and select the one you need.
- Tested only on SublimeText 3 (So please report about ST2 if it has any problems or works as desired).
- Not tested with huge data, It might become slow with big files since it is using
insert_snippet
command internally.