How to auto-escape a special char in VS Code Snippets?
I want to write a snippet for Debugging in TYPO3.
This is my Snippet-Code in php.json file:
"TYPO3 Extbase DebuggerUtility": {
"prefix": "ee",
"body": [
"\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($1,'$1');",
"$0"
],
"description": "TYPO3 Extbase DebuggerUtility"
},
If I want to debug something liket this : $this->settings['key'] I get this code:
TYPO3CMSExtbaseUtilityDebuggerUtility::var_dump($this->settings['key'],'$this->settings['key']');
But it should looks like this
TYPO3CMSExtbaseUtilityDebuggerUtility::var_dump($this->settings['key'],'$this->settings['key']');
With escaped ' in the second part of that snippet.
EDIT
Thank you, but I think you missunderstood the question.
I don't want to escape a static character. I want to use the snippet and when I type the first $1-content it should be $this->settings['someKey'] but the second $1 (which is near the same) should automatically escape the ' chars I write, that I don't do this manually by hand.
So if i type '
first $1: '
second $1: '
that my Debug looks like this
Debug:
$this->settings['someKey']
contentOfsomeKey
I I don't escape the ' signs inside the "title of the debug" it breaks the string because ' wraps the debug-title.
In other words: I want to escape the content of the second $1 variable not the variable or the '-wrap in the snippet.
I hope I could clarify my issue.
visual-studio-code code-snippets
add a comment |
I want to write a snippet for Debugging in TYPO3.
This is my Snippet-Code in php.json file:
"TYPO3 Extbase DebuggerUtility": {
"prefix": "ee",
"body": [
"\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($1,'$1');",
"$0"
],
"description": "TYPO3 Extbase DebuggerUtility"
},
If I want to debug something liket this : $this->settings['key'] I get this code:
TYPO3CMSExtbaseUtilityDebuggerUtility::var_dump($this->settings['key'],'$this->settings['key']');
But it should looks like this
TYPO3CMSExtbaseUtilityDebuggerUtility::var_dump($this->settings['key'],'$this->settings['key']');
With escaped ' in the second part of that snippet.
EDIT
Thank you, but I think you missunderstood the question.
I don't want to escape a static character. I want to use the snippet and when I type the first $1-content it should be $this->settings['someKey'] but the second $1 (which is near the same) should automatically escape the ' chars I write, that I don't do this manually by hand.
So if i type '
first $1: '
second $1: '
that my Debug looks like this
Debug:
$this->settings['someKey']
contentOfsomeKey
I I don't escape the ' signs inside the "title of the debug" it breaks the string because ' wraps the debug-title.
In other words: I want to escape the content of the second $1 variable not the variable or the '-wrap in the snippet.
I hope I could clarify my issue.
visual-studio-code code-snippets
There are a number of answers already on this; see, e.g., stackoverflow.com/questions/52302768/…
– Mark
Nov 21 '18 at 15:34
thx @Mark / Bernd - I updated my question, your answers doesn't fit my question
– MonTea
Nov 22 '18 at 8:20
add a comment |
I want to write a snippet for Debugging in TYPO3.
This is my Snippet-Code in php.json file:
"TYPO3 Extbase DebuggerUtility": {
"prefix": "ee",
"body": [
"\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($1,'$1');",
"$0"
],
"description": "TYPO3 Extbase DebuggerUtility"
},
If I want to debug something liket this : $this->settings['key'] I get this code:
TYPO3CMSExtbaseUtilityDebuggerUtility::var_dump($this->settings['key'],'$this->settings['key']');
But it should looks like this
TYPO3CMSExtbaseUtilityDebuggerUtility::var_dump($this->settings['key'],'$this->settings['key']');
With escaped ' in the second part of that snippet.
EDIT
Thank you, but I think you missunderstood the question.
I don't want to escape a static character. I want to use the snippet and when I type the first $1-content it should be $this->settings['someKey'] but the second $1 (which is near the same) should automatically escape the ' chars I write, that I don't do this manually by hand.
So if i type '
first $1: '
second $1: '
that my Debug looks like this
Debug:
$this->settings['someKey']
contentOfsomeKey
I I don't escape the ' signs inside the "title of the debug" it breaks the string because ' wraps the debug-title.
In other words: I want to escape the content of the second $1 variable not the variable or the '-wrap in the snippet.
I hope I could clarify my issue.
visual-studio-code code-snippets
I want to write a snippet for Debugging in TYPO3.
This is my Snippet-Code in php.json file:
"TYPO3 Extbase DebuggerUtility": {
"prefix": "ee",
"body": [
"\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($1,'$1');",
"$0"
],
"description": "TYPO3 Extbase DebuggerUtility"
},
If I want to debug something liket this : $this->settings['key'] I get this code:
TYPO3CMSExtbaseUtilityDebuggerUtility::var_dump($this->settings['key'],'$this->settings['key']');
But it should looks like this
TYPO3CMSExtbaseUtilityDebuggerUtility::var_dump($this->settings['key'],'$this->settings['key']');
With escaped ' in the second part of that snippet.
EDIT
Thank you, but I think you missunderstood the question.
I don't want to escape a static character. I want to use the snippet and when I type the first $1-content it should be $this->settings['someKey'] but the second $1 (which is near the same) should automatically escape the ' chars I write, that I don't do this manually by hand.
So if i type '
first $1: '
second $1: '
that my Debug looks like this
Debug:
$this->settings['someKey']
contentOfsomeKey
I I don't escape the ' signs inside the "title of the debug" it breaks the string because ' wraps the debug-title.
In other words: I want to escape the content of the second $1 variable not the variable or the '-wrap in the snippet.
I hope I could clarify my issue.
visual-studio-code code-snippets
visual-studio-code code-snippets
edited Nov 21 '18 at 15:45
MonTea
asked Nov 21 '18 at 10:50


MonTeaMonTea
288315
288315
There are a number of answers already on this; see, e.g., stackoverflow.com/questions/52302768/…
– Mark
Nov 21 '18 at 15:34
thx @Mark / Bernd - I updated my question, your answers doesn't fit my question
– MonTea
Nov 22 '18 at 8:20
add a comment |
There are a number of answers already on this; see, e.g., stackoverflow.com/questions/52302768/…
– Mark
Nov 21 '18 at 15:34
thx @Mark / Bernd - I updated my question, your answers doesn't fit my question
– MonTea
Nov 22 '18 at 8:20
There are a number of answers already on this; see, e.g., stackoverflow.com/questions/52302768/…
– Mark
Nov 21 '18 at 15:34
There are a number of answers already on this; see, e.g., stackoverflow.com/questions/52302768/…
– Mark
Nov 21 '18 at 15:34
thx @Mark / Bernd - I updated my question, your answers doesn't fit my question
– MonTea
Nov 22 '18 at 8:20
thx @Mark / Bernd - I updated my question, your answers doesn't fit my question
– MonTea
Nov 22 '18 at 8:20
add a comment |
1 Answer
1
active
oldest
votes
If you want escape characters in your output you need to insert escaped escape characters:
\
this should result in single escape characters.
You might need an additional escape character if the following character needs an additional escaping: one backslash before quote '
= \
+ '
= \'
`
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410470%2fhow-to-auto-escape-a-special-char-in-vs-code-snippets%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want escape characters in your output you need to insert escaped escape characters:
\
this should result in single escape characters.
You might need an additional escape character if the following character needs an additional escaping: one backslash before quote '
= \
+ '
= \'
`
add a comment |
If you want escape characters in your output you need to insert escaped escape characters:
\
this should result in single escape characters.
You might need an additional escape character if the following character needs an additional escaping: one backslash before quote '
= \
+ '
= \'
`
add a comment |
If you want escape characters in your output you need to insert escaped escape characters:
\
this should result in single escape characters.
You might need an additional escape character if the following character needs an additional escaping: one backslash before quote '
= \
+ '
= \'
`
If you want escape characters in your output you need to insert escaped escape characters:
\
this should result in single escape characters.
You might need an additional escape character if the following character needs an additional escaping: one backslash before quote '
= \
+ '
= \'
`
answered Nov 21 '18 at 14:03


Bernd Wilke πφBernd Wilke πφ
5,0671824
5,0671824
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410470%2fhow-to-auto-escape-a-special-char-in-vs-code-snippets%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
There are a number of answers already on this; see, e.g., stackoverflow.com/questions/52302768/…
– Mark
Nov 21 '18 at 15:34
thx @Mark / Bernd - I updated my question, your answers doesn't fit my question
– MonTea
Nov 22 '18 at 8:20