SublimeBufmod
Operations on text selections for SublimeText2
Details
Installs
- Total 428
- Win 209
- Mac 97
- Linux 122
Dec 21 | Dec 20 | Dec 19 | Dec 18 | Dec 17 | Dec 16 | Dec 15 | Dec 14 | Dec 13 | Dec 12 | Dec 11 | Dec 10 | Dec 9 | Dec 8 | Dec 7 | Dec 6 | Dec 5 | Dec 4 | Dec 3 | Dec 2 | Dec 1 | Nov 30 | Nov 29 | Nov 28 | Nov 27 | Nov 26 | Nov 25 | Nov 24 | Nov 23 | Nov 22 | Nov 21 | Nov 20 | Nov 19 | Nov 18 | Nov 17 | Nov 16 | Nov 15 | Nov 14 | Nov 13 | Nov 12 | Nov 11 | Nov 10 | Nov 9 | Nov 8 | Nov 7 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 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 | 0 | 0 | 0 | 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Linux | 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 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
Description
Bufmod is a package for SublimeText2 that contains various commands to manipulate the current text selection in useful ways.
Installation
You can install this package by running the following command in your ST2 Packages directory:
git clone git://github.com/minism/SublimeBufmod.git
Once installed, be sure to edit the appropriate keybinding config file, as the keys are blank by default. The files are:
- Default (Linux).sublime-keymap
- Default (OSX).sublime-keymap
- Default (Windows).sublime-keymap
Commands
You can run commands by using the key shortcuts, or through the command menu by pressing Ctrl/Cmd+P and typing “Bufmod”. All commands require one or more active selections of text in your editor to have any effect.
Apply function to selection
This is a simple yet powerful command. An input window will open up which accepts a python function as a string, on a single line, with the following constraints:
- The variable
s
is a unicode object containing the selected text. - The function must return a unicode or string.
The possibilities are really endless here. Some examples of what you can do:
return str(len(s))
return s.encode('ascii')
return s.strip().upper().center(80)
Or, perhaps something more complicated (make sure to use semicolons!):
import os; return '\n'.join(os.path.join(os.path.expanduser('~'), chunk.strip()) for chunk in s.split(','))
Which would turn this:
images, scripts, notes
Into:
/Users/josh/images
/Users/josh/scripts
/Users/josh/notes
Apply function to each line in selection
Similar to the previous command, except for the following differences:
- The function is mapped to every line in the selection.
- The variable
s
is a unicode object containing the text for a single line. - The value returned replaces a single line.
This (ideally) obviates the need to use split and join in your function to process multiple lines.
Decorate text with border
An input window opens which accepts a single character (extra characters are discarded). The current selection is wrapped in a padded box using the specified character.
Example:
bufmod.py - SublimeText2 Helper
Becomes:
###################################
# #
# bufmod.py - SublimeText2 Helper #
# #
###################################
Discussion
Forum thread: http://www.sublimetext.com/forum/viewtopic.php?f=5&t=3677