Home Download Buy Blog Forum Support

SublimeBufmod: Simple operations on the text selection

SublimeBufmod: Simple operations on the text selection

Postby minism on Tue Nov 08, 2011 10:56 am

Hey guys,

This package mainly consists of a single convenience command that I created for myself that I have been using daily. Activate the command and an input window pops up, into it you type a python function which takes the variable 's' as the current text selection and returns a string. It then runs the function on all of your active text selections and replaces them.

So, in essence you would type something like this:
Code: Select all
return s.strip().upper().center(80)

The command is a little bit hacky as it uses exec() so don't expect this to be terribly robust :)

I also added a simple command to decorate text with a border...
Code: Select all
###########
#         #
# Like so #
#         #
###########


The package is available here: https://github.com/minism/SublimeBufmod

Should be on PackageControl shortly.
minism
 
Posts: 8
Joined: Tue Nov 01, 2011 5:30 am

Re: SublimeBufmod: Simple operations on the text selection

Postby danield on Tue Jul 03, 2012 5:55 pm

I was actually really excited about this because I was hoping to use it for block comments in ASP (vbscript). The problem is Sublime thinks ASP uses html comments (<!-- -->) which is totally wrong. Instead, a comment in ASP is just an apostrophe. There are also actually no "block" comments and every line you want to comment out must be prepended with a single quote '

Your addon helps a lot in that I can execute the bufmod_apply_function_lines function and add in ' + to comment out several lines. I have to do this a lot though and it will be really useful if you could somehow setup python functions ahead of time and then simply have the appropriate keyboard shortcut fire the command. If you know of any other package that would let me do this or could update yours to have that functionality it would be awesome! I imagine you could even just have like 10 commands that link to custom python functions and they could be mapped at will to whatever keyboard shortcuts the user wants.

Thanks for this addon, for now it at least makes multiple line commenting in ASP possible! I just hope to get it more streamlined.
danield
 
Posts: 4
Joined: Tue Jul 03, 2012 5:51 pm

Re: SublimeBufmod: Simple operations on the text selection

Postby minism on Tue Aug 07, 2012 11:40 pm

danield wrote:I was actually really excited about this because I was hoping to use it for block comments in ASP (vbscript). The problem is Sublime thinks ASP uses html comments (<!-- -->) which is totally wrong. Instead, a comment in ASP is just an apostrophe. There are also actually no "block" comments and every line you want to comment out must be prepended with a single quote '

Your addon helps a lot in that I can execute the bufmod_apply_function_lines function and add in ' + to comment out several lines. I have to do this a lot though and it will be really useful if you could somehow setup python functions ahead of time and then simply have the appropriate keyboard shortcut fire the command. If you know of any other package that would let me do this or could update yours to have that functionality it would be awesome! I imagine you could even just have like 10 commands that link to custom python functions and they could be mapped at will to whatever keyboard shortcuts the user wants.

Thanks for this addon, for now it at least makes multiple line commenting in ASP possible! I just hope to get it more streamlined.


Agreed, I find myself doing common operations quite a lot. Perhaps they could be specified in a configuration file for the plugin? Like a list of functions with key mappings? I will have to think about this
minism
 
Posts: 8
Joined: Tue Nov 01, 2011 5:30 am


Return to Plugin Announcements

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest