ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Change​Quotes

Converts single to double or double to single quotes. Attempts to preserve correct escaping, though this could be improved I'm sure.

Details

Installs

  • Total 50K
  • Win 22K
  • Mac 18K
  • Linux 10K
May 31 May 30 May 29 May 28 May 27 May 26 May 25 May 24 May 23 May 22 May 21 May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12 May 11 May 10 May 9 May 8 May 7 May 6 May 5 May 4 May 3 May 2 May 1 Apr 30 Apr 29 Apr 28 Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17
Windows 0 3 3 1 1 3 1 1 3 1 2 0 1 0 1 1 0 0 2 2 1 1 0 0 3 3 1 0 5 2 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 2 0 1 0 1 2 0 1 0 0 0 0 0 2 0 1 2 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 3 1 2 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

ChangeQuotes

Converts single to double or double to single quotes. Attempts to preserve correct escaping, though this could be improved I'm sure.

Installation

Using Package Control, install “ChangeQuotes” or clone this repo in your packages folder.

I recommended you add key bindings for the commands. I've included my preferred bindings below. Copy them to your key bindings file (⌘⇧,).

Key Bindings

Copy these to your user key bindings file.

{ "keys": ["ctrl+shift+'"], "command": "change_quotes" },

How to use

Put your cursor inside the text that is in quotes and then execute the command to replace the quotes. No selection needed.

How to customize

Different languages have different quotes, and this plugin tries to support them all!

Open up ChangeQuotes.sublime-settings to see the default config. You can get there from the menu bar:

Preferences > Package Settings > Change Quotes > Settings - Default

There are two per-language settings you should pay attention to:

prefixes - This helps with the string searching; in python, a string can start with an identifier like u or r, and these will be “skipped” when changing quotes.

quotes - This list-of-lists defines all the quote characters that can be cycled. If you are using ES6, and want to add support for backtick-strings / interpolation-strings, you just need to add the backtick character to this list!

// without backtick-strings:
"source.js": {
  "quotes": [["'", "\""]]
}
// with backtick-string support (ES6-only):
"source.js": {
  "quotes": [["'", "\"", "`"]]
}

Commands

change_quotes: Converts from single to double quotes. Uses the Sublime Text grammar parsing, so it doesn't always “find” the quotes, for instance MarkDown doesn't define special “string” syntax, and so this plugin can't be used. The upside is we don't have to write / maintain a complex matching quote algorithm.