With Python
"Replace with Python" for Sublime Text 2
Details
Installs
- Total 665
- Win 483
- Mac 77
- Linux 105
Sep 14 | Sep 13 | Sep 12 | Sep 11 | Sep 10 | Sep 9 | Sep 8 | Sep 7 | Sep 6 | Sep 5 | Sep 4 | Sep 3 | Sep 2 | Sep 1 | Aug 31 | Aug 30 | Aug 29 | Aug 28 | Aug 27 | Aug 26 | Aug 25 | Aug 24 | Aug 23 | Aug 22 | Aug 21 | Aug 20 | Aug 19 | Aug 18 | Aug 17 | Aug 16 | Aug 15 | Aug 14 | Aug 13 | Aug 12 | Aug 11 | Aug 10 | Aug 9 | Aug 8 | Aug 7 | Aug 6 | Aug 5 | Aug 4 | Aug 3 | Aug 2 | Aug 1 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
Mac | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
Linux | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
Sublime Text “Replace with Python”
Sublime Text has a great regex-powered find-and-replace feature. But, what if you want to do a little more complex replacement? “Replace with Python” empowers your replace command with Python, letting you do advanced text manipulation intuitively and easily.
Commands
- “With Python: Replace”, accessible as
Find => Replace with Python
(with_python_prompt_replace
)- Select some regions of text, e.g. by alt+dragging a rectangular area or by using
Find => Find...
followed by alt+enter to select all matches. - Activate this command to bring up a command entry box
- Type a Python statement (or multiple statements separated by newlines, which you can enter with
alt+enter
), which uses thetext
and/orindex
variables and ultimately assigns thetext
variable. - Your snippet will be executed once per selection region, with the output
text
variable replacing the selected text.
- Select some regions of text, e.g. by alt+dragging a rectangular area or by using
- “With Python: Sort Lines”, accessible as
Edit => Sort Lines with Python
(with_python_prompt_sort_lines
)- Optionally, select some regions of text. Each region will be sorted independently. The entire file is sorted if nothing is selected.
- Activate this command to bring up a command entry box.
- Type a Python expression which uses the
line
and/orindex
variables. The result of this expression is used as a sort key. - The expression is executed once per line in a selection region, and the lines are sorted according to the resulting values.
- “With Python: Sort Selections”, accessible as
Edit => Sort Selections with Python
(with_python_prompt_sort_selections
)- Select some regions of text.
- Activate this command to bring up a command entry box
- Type a Python expression which uses the
text
and/orindex
variables. - The expression is executed once per selection region, and the regions are moved according to the resulting values. Unselected text is not affected.
Variables
text
- Selected text. Usable inReplace With Python
andPermute Selections => Sort With Python
.line
- Line within a selection. Usable inPermute Lines => Sort With Python
.index
- 0-based index of the current selection region. Usable in all functions.lineno
- Line number within the current selection. Usable inPermute Lines => Sort With Python
.