Vscode: Allow auto-close quotation marks per file type and global

Created on 29 Apr 2017  路  15Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.12.0 - insiders
  • OS Version: Windows 10

-- Sorry for the English, I used Google Translator --

After a long conversation with @alexandrudima the same suggested that he open that issue.
@alexandrudima, I do not know if that's what you imagined .. so feel free to edit.

By default all single and double quotation marks should auto close if you have words + space.
By default all single and double quotation marks should not close if it is next to the word. For single quotes should be considered apostrophe.

Here are examples of how to share the quotes. Similiar to Atom and Sublime.

Eg1:
ex1

Eg2:
ex2

Allow the same to be set up separately for comments. (This is the javascript that auto closes single quotation marks in code, but not when used in comments.) By default it should follow the above rules.

There may be a question of syntactic and semantic, depending on the language. So let the resource by language.

There are still letters that allow you to have apostrophes along with single quotes. It does not interfere with semantics and maintains syntax highlighting.

*out-of-scope editor-autoclosing feature-request

Most helpful comment

editor.autoClosingBrackets doesn't work to auto close quotation marks on Mac

Somebody have any idia why?

All 15 comments

+1
I could not find any extensions, too.

I have pushed a change where ' and " do not auto-close if inserted after a word character (as defined via editor.wordSeparators), in the cases that ' and " are defined to be auto closing pairs by the language configuration.

@alexandrudima Is this change for all languages?

The weekend I take it easy, but at first I tested HTML, JavaScript, Properties and C ++ (because you had spoken in the other case :smile:). And Properties did not work.

From the first moment that would be the idea !! :smiley:

Related, but possibly a separate feature request: I'd love to have a setting to disable automatic quote insertion altogether. Assuming it's not already there and I can't find it. It's wrong enough that the time spent fighting it makes it kind of a wash. The suggestions above would definitely improve it, but I just don't think it's so necessary.

Other common patterns I run into:

  • I insert a missing close quote and it gives me two quotes. I delete the extra quote and it deletes both.
  • I want to change between single and double quotes. I select the first quote, press cmd+d to select the next, press the new kind of quote, and end up with six.

I propose that editor.autoClosingBrackets would have 3 states:

  • true - the way it is now
  • false - disabling it completely
  • "always" - close single quotes, double quotes, brackets always

editor.autoClosingBrackets doesn't work to auto close quotation marks on Mac

Somebody have any idia why?

Having this problem too.

@perdona I solved that problem creating a snippet for JS files with ' and "

  "Close quotation marks": {
    "prefix": "'",
    "body": [
      "'$1'"
    ],
    "description": "Autoclose quotation marks"
  },
  "Close quotation marks double": {
    "prefix": "\"",
    "body": [
      "\"$1\""
    ],
    "description": "Autoclose quotation marks"
  }

@nathpaiva where do I put it? Sorry, new to vscode. Also, can I do the same with Python? Thx

Files / Preferences / User snippets

@perdona command + shift + p > open user snippets > and choose the type of file you want to use

Still not working guys. After saving the snippets, my single and double quotes are still not autoclosing.

@perdona with snippets will work with after press tab

Hello, i solved this issue with this extension: https://marketplace.visualstudio.com/items?itemName=konstantin.wrapSelection

i hope this feature could be by default in coming versions.

Thanks.

This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding and happy coding!

Was this page helpful?
0 / 5 - 0 ratings