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

Change​Quotes

by Colin T.A. Gray (colinta) ST2/ST3 Trending

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
  • 12 months ago
  • 1 hour ago
  • 5 years ago

Installs

  • Total 25K
  • Win 9K
  • OS X 12K
  • Linux 5K
Jun 27 Jun 26 Jun 25 Jun 24 Jun 23 Jun 22 Jun 21 Jun 20 Jun 19 Jun 18 Jun 17 Jun 16 Jun 15 Jun 14 Jun 13 Jun 12 Jun 11 Jun 10 Jun 9 Jun 8 Jun 7 Jun 6 Jun 5 Jun 4 Jun 3 Jun 2 Jun 1 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
Windows 0 8 3 3 6 5 3 2 5 2 2 6 6 2 6 1 2 1 4 4 2 2 4 1 3 2 4 5 2 0 2 1 5 4 1 3 1 4 2 5 4 2 2 5 2 5
OS X 1 5 4 2 6 5 5 8 8 6 1 3 6 8 7 7 2 1 7 3 2 11 3 2 3 9 3 3 6 3 4 1 1 4 4 4 6 0 5 5 7 2 7 8 1 2
Linux 0 2 3 1 2 2 0 3 2 0 2 2 2 3 1 0 0 1 0 2 3 2 4 4 0 2 3 1 0 2 3 1 1 1 5 3 4 0 1 3 2 1 4 4 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

  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

  3. Install keymaps for the commands (see Example.sublime-keymap for my preferred keys)

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.