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
  • 2 years ago
  • 2 hours ago
  • 6 years ago

Installs

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