Sublime Forum

Replace text by running external command, like Vim's : <range> ! <script>

#1

I’ve been looking for this in Sublime Text 3, and haven’t found it yet:

In Vim, it’s possible to replace a range of lines (or the whole buffer) with the results of running a shell command:

: % ! sort

or

: 5,20 ! sort

where sort is some Unix filter that reads STDIN and writes to STDOUT. (Obviously sort is an example.)

Is this possible in ST3?

Edit for context: On TextMate, it was I think called Filter Selection Through Command. On BBedit/TextWrangler it’s Text Filters (on the #! menu). On Emacs it’s something weird like C-u M-| shell-command-on-region. On Atom I don’t think its provided on the base system. I would be surprised if ST3 didn’t have it somewhere, but I can’t find it yet.

0 Likes

#2

Definitively doable with a plugin, I’m not a plugin master yet, but there is a function that give you the current selection and another one for inserting text so it shouldn’t be really hard to create one that does what you want.

0 Likes

#3

I think SublimeTextShellCommand will do this! Haven’t tried it yet, but it looks like it is the missing feature I’ve been looking for.

0 Likes