I want to set up automatic text replacement shortcuts in Visual Studio Code similar to snippets in SQL Complete or text replacements on iOS. So for example: if I type ssf I want VS Code to replace it with SELECT * FROM. (Or alternatively, offer it as an autocomplete suggestion).
How can I set up automatic text replacement rules in VS Code?
you can use extensions such as the "JavaScript (ES6) code snippets"
Related
I cannot locate the settings or other configurations that define the colors and other formatting shown in VS Code's Terminal output. I'd like to mimic or use these settings elsewhere, such as in word processing software, HTML/CSS, or simply a Language Mode when copying & pasting the output into a new VS Code file.
Where is this formatting defined? Also, how can I keep this formatting intact when using the text elsewhere?
The built-in markdown editor has a "live-preview" for code blocks without open a side previewer.
I was looking for a list of supported language highlight, which as I understand is defined by highlight.js supported language.
I need to add some "ssh config files" in my markdown, but
when I use properties language tag, only side previewer shows the highlight, not the editor itself
when I try with a weird "s" language alias, the editor can detect the comments and non-alphabetic characters. But the side previewer shows nothing...
VSCode screenshot:
My questions:
"s" is not defined as an alias in highlight.js, then how come the editor can detect the language?
Why the editor and previewer do not have the same highlight behavior?
I prefer to have the correct highlight in editor, which language/alias should I use in place of "properties"?
Summarizing previous comments and answers here:
VScode markdown "in-editor" code highlight use "markdown-basic" extension, with a list of supported languages in this file
The "alias" for different languages are "hidden" in the regex of each block definition. for example for R language the alias is R|r|s|S|Rprofile|\\{\\.r.+?\\}. (I extract a complete list of aliases from the source codes and it is shown below)
More specifically for what I want, i.e. key-value pair config file equivalent to properties in highlight.js, there is no exact the same in "markdown-basic", so I will use conf.
Developer: Inspect Editor Tokens and Scopes helps a lot when you see a unfamiliar alias and want to know what it is
List of code block languages aliases for "markdown-basic":
bat|batch
bibtex
c|h
clj|cljs|clojure
coffee|Cakefile|coffee.erb
COMMIT_EDITMSG|MERGE_MSG
cpp|c\\+\\+|cxx
cs|csharp|c#
css|css.erb
dart
dockerfile|Dockerfile
elixir
erlang
fs|fsharp|f#
git-rebase-todo
go|golang
groovy|gvy
handlebars|hbs
html|htm|shtml|xhtml|inc|tmpl|tpl
ini|conf
jade|pug
java|bsh
js|jsx|javascript|es6|mjs|cjs|\\{\\.js.+?\\}
json|json5|sublime-settings|sublime-menu|sublime-keymap|sublime-mousemap|sublime-theme|sublime-build|sublime-project|sublime-completions
jsonc
latex|tex
less
log
lua
Makefile|makefile|GNUmakefile|OCamlMakefile
markdown|md
objectivec|objective-c|mm|objc|obj-c|m|h
patch|diff|rej
perl|pl|pm|pod|t|PL|psgi|vcl
perl6|p6|pl6|pm6|nqp
php|php3|php4|php5|phpt|phtml|aw|ctp
powershell|ps1|psm1|psd1
python|py|py3|rpy|pyw|cpy|SConstruct|Sconstruct|sconstruct|SConscript|gyp|gypi|\\{\\.python.+?\\}
R|r|s|S|Rprofile|\\{\\.r.+?\\}
re
regexp
ruby|rb|rbx|rjs|Rakefile|rake|cgi|fcgi|gemspec|irbrc|Capfile|ru|prawn|Cheffile|Gemfile|Guardfile|Hobofile|Vagrantfile|Appraisals|Rantfile|Berksfile|Berksfile.lock|Thorfile|Puppetfile
rust|rs|\\{\\.rust.+?\\}
scala|sbt
scss
shell|sh|bash|zsh|bashrc|bash_profile|bash_login|profile|bash_logout|.textmate_init|\\{\\.bash.+?\\}
sql|ddl|dml
swift
tsx
typescript|ts
vb
xml|xsd|tld|jsp|pt|cpt|dtml|rss|opml
xsl|xslt
yaml|yml
I don't believe VSCode's native syntax highlighting has anything to do with highlight.js. It is provided by language-specific extensions, some of which ship with the editor.
In this case, VSCode is using its built-in R mode for that code block. You can see the language being used via Developer: Inspect Editor Tokens and Scopes in the command palette. R is an open-source implementation of the language S, so this makes sense.
The Markdown preview, on the other hand, may well use highlight.js and you are right that s is meaningless there.
I don't see a good language code to use in your code fence, but will update this answer if I find one.
The first syntax highlighting is of VS Code and the second one is of Sublime Text. I searched for extensions but I couldn't find anything which could detect SQL commands like CREATE TABLE and highlight them or suggest them as I start typing.
Sublime Text and Atom have this feature by default, but I can't get it to work in VS Code.
I am working with .py files so the syntax highlighting works only for Python commands and the whole text (inside quotes) is treated as string in VS Code.
Is there any fix to get syntax highlighting like Sublime Text / Atom in VS Code when working with SQL syntax in .py files or highlighting commands even if it's inside quotes ("")?
It seems the VS Code doesn't support this feature officially.
Hence, I make an extension called Highlight String Code which can highlight SQL expressions in Python or any other language.
You can easily use it by uppercasing the first keyword of the SQL command and adding a semicolon at the end:
I hope the extension can be helpful.
This is the inverse of How to manually set language for syntax highlighting in Visual Studio Code
Basically what I'd want is something similar in VI where it will detect some string that would specify the format of a file specifically for Azure Pipelines
# --language-mode: azure-pipelines
Or something similar.
you can write an extension that uses vscode.languages.setTextDocumentLanguage
like the extension Change Language Mode.
Add a hook for document change and open and analyse the content and search for a particular string and set the mode if it is different.
Configure the strings to search for and the language id to set in the settings
I want to keep track of a todo list in Visual Studio Code.
Is it possible to display/toggle strikethrough text:
task not yet done
̶t̶a̶s̶k̶ ̶d̶o̶n̶e̶
(used https://www.piliapp.com/cool-text/strikethrough-text/ for the above).
Looking for a solution natively or with an extension. The strike-through text needs to be displayed in the text file (like the functioning of org mode in emacs) and not in some output window (like the rendering of a HTML/Latex/MD document).
Any experts in Visual Studio Code that know if this can be done and how to do it ?
You can make strikethrough in vscode with the help of TODO Highlight extension:
"todohighlight.keywordsPattern": "(~~.+?~~)|(✔.+?\n)|(\\[x\\].+\n)",
"todohighlight.defaultStyle": {
"color": "none",
"backgroundColor": "none",
"textDecoration": "line-through"
},
Use patterns that you usually use for done todos. The above works for such:
[x] done
✔ done
~~done~~
After that you can either use plain typing or find some toggling extension or write one yourself.
Try the extension "Strike for VSCode", looks very lightweight extension.
Highlight the text you want to strikethrough and hit CTRL K + backspace.
CTRL K + backspace again to toggle.
You can use the built in function of adding "~~" before and after the text
so its like:
~~strikethrough~~
which strikes the words in between.
This can be done without extensions.