Sublime Forum

Exec Parser: Parse the content before you paste or duplicate

#1

[size=150]Exec Parser[/size]

https://github.com/edankwan/Exec-Parser-Sublime-Plugin

What it does is super simple - Run a python script file to parse the text. It is my first plugin and it is also my time using Python. Hope you guys like it and file issue on github to help it grow. It is already on Package Control. Try searching “Exec Parser” and you will get it :smile:

By default, there are 6 default commands you can use after you installed it:

*]none - Do nothing *]dash-case - Convert to dash case *]snake_case - Convert to snake case *]camelCase - Convert to camel case *]X to Y - Convert X to Y, Width to Height and so on *]Swap equal positions - Change var a = b; into var b = a;

By default, the commands for copy/duplicate line are both “none”, I recommend you to change the default hotkeys of them to the native ones as if you dont use any special commands, it can behave exactly like the native ones.

Default hotkey for paste command is Ctrl+Shift+v and for duplicate line command is Ctrl+Shift+c

Let 's say you want to use “X to Y” command for duplicate line, hit Ctrl+Shift+x to call out the command list panel. select “X to Y” > enter > duplicate only. Then when you try to duplicate the line:

var width = x + containerWidth;

It will become:

var height = y + containerHeight;

Awesome right?

But the coolest part of this plugin is not just the default commands. You can create your own commands as well.

[size=150]Create your own command[/size]

Let 's say you want to create a command to wrap the context with bracket ]. Hit “Ctrl+Shift+z” to call out the “user option” panel, choose “add new command”, type in a filename without extension for example: “bracket-wrapper”. Hit enter, it will open 2 files: commands.json(for name,description,…) and a python script file. Type the following line in the python file:

output = '' + output + ']'

Save it and hit “Ctrl+Shift+z” again to call out the “user option” panel, choose “Reinitialize Plugin”. Then you will find that there will be a new command in the command panel.

Easy enough! For more information, just check out the github repo: https://github.com/edankwan/Exec-Parser-Sublime-Plugin

Please share your awesome command by making a pull request :smile:

Edan

0 Likes