Home Download Buy Blog Forum Support



Postby spadgos on Wed Nov 09, 2011 6:08 pm

A plugin which will toggle the string quoting style of your selected text.

Step 1: Select some text including the quotes, eg: "hello world"
Step 2: Hit the opposite quote, in this example, '
Result: 'hello world'

Obviously, it works for converting single-to-double quotes too.

As a bonus, it will automatically escape any quote marks which now need escaping, and unescape those which no longer need it.
Code: Select all
Select: "It's \"awesome\""
Press: '
Result: 'It\'s "awesome"'
Press: "
Result: "It's \"awesome\""

It works with multiple selections, however, unless all the selections have the same original quoting style (eg: all single quoted, or all double quoted), you have to press the hotkey to activate it: Ctrl+'

Installation via Package Control
Code/bug reports/feature requests at: https://github.com/spadgos/sublime-ToggleQuotes
Posts: 121
Joined: Thu Oct 06, 2011 12:49 am

Re: ToggleQuotes

Postby buhrmi on Thu Nov 10, 2011 4:32 am

I needed this!

Would it be hard to include converting brackets (() <-> [] <-> {}) too?
Posts: 17
Joined: Tue Nov 08, 2011 5:59 am

Re: ToggleQuotes

Postby facelessuser on Thu Nov 10, 2011 5:32 am

You can try bracket highlighters here.

Seeing your request I added a quick plugin command for to change current bracket to {}, [], (), or <> via the quick panel. Bracket Highlighter has a simple plugin system for tapping into to finding brackets. Swap Brackets only works on single selections right now, but in the future it could be reworked to work on multi.

Bracket Highlighter also has quote swapping (scope based).

Edit: Now supports multi-select for bracket swapping
Posts: 1647
Joined: Tue Apr 05, 2011 7:38 pm

Re: ToggleQuotes

Postby Gordio on Sun Nov 13, 2011 11:55 pm

This analog surround for VIM? :P
Posts: 13
Joined: Sun Oct 02, 2011 2:00 pm

Re: ToggleQuotes

Postby spadgos on Mon Nov 14, 2011 2:45 pm

@Gordio: could you explain that?
Posts: 121
Joined: Thu Oct 06, 2011 12:49 am

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 14 guests