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

  • 2 2013.07.09.15.13.05
    3 2.3.1
  • github.​com
  • github.​com
  • 1 year ago
  • 1 hour ago
  • 6 years ago

Installs

  • Total 25K
  • Win 9K
  • OS X 12K
  • Linux 5K
Aug 24 Aug 23 Aug 22 Aug 21 Aug 20 Aug 19 Aug 18 Aug 17 Aug 16 Aug 15 Aug 14 Aug 13 Aug 12 Aug 11 Aug 10 Aug 9 Aug 8 Aug 7 Aug 6 Aug 5 Aug 4 Aug 3 Aug 2 Aug 1 Jul 31 Jul 30 Jul 29 Jul 28 Jul 27 Jul 26 Jul 25 Jul 24 Jul 23 Jul 22 Jul 21 Jul 20 Jul 19 Jul 18 Jul 17 Jul 16 Jul 15 Jul 14 Jul 13 Jul 12 Jul 11 Jul 10
Windows 0 6 2 3 0 1 5 6 2 5 7 4 1 1 5 1 5 2 7 1 5 3 7 5 3 5 3 3 7 3 4 4 4 1 2 6 7 4 4 6 0 2 6 3 9 3
OS X 2 5 10 3 4 3 7 4 12 4 6 3 5 0 4 9 9 4 4 1 6 4 5 5 3 0 2 8 2 4 5 3 4 2 8 11 7 3 4 2 4 8 5 7 4 4
Linux 0 2 3 0 3 1 1 4 2 3 4 2 0 3 1 2 2 2 2 1 6 0 8 1 4 1 1 3 3 4 2 1 1 0 2 4 2 3 1 1 0 2 3 4 1 3

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

  1. Using Package Control, install “ChangeQuotes”

Or:

  1. Open the Sublime Text Packages folder

    • OS X: ~/Library/Application Support/Sublime Text 3/Packages/
    • Windows: %APPDATA%/Sublime Text 3/Packages/
    • Linux: ~/.Sublime Text 3/Packages/ or ~/.config/sublime-text-3/Packages
  2. Clone this repo

Keymaps

Put the following inside your .sublime_keymap (Sublime Text -> Preferences -> Key Bindings):

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

Now you can toggle quotes with CTRL+Shift+'.

Sublime Text 2

  1. Open the Sublime Text 2 Packages folder
  2. clone this repo, but use the st2 branch

    git clone -b st2 git@github.com:colinta/SublimeChangeQuotes

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.