Where is the Terminal's formatting defined in VS Code? - visual-studio-code

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?

Related

Grammar checker in VS CODE

I need to check the grammar of various docstrings, is there a way to do that directly in Visual Studio Code (or any other editor) without copying and pasting each docstring in a grammar checker like Grammarly?
At the bottom of the extension settings for Grammarly, under Grammarly>Files: Include you could add python files to be checked, by adding:
**/*.py
Note, this would include the whole python file and not just the docstrings.

How can do auto-indent upon newline in VS Code like this

In this situation,
When I add newline at if (level >= curr_log_level),
at this setting,
It becomes
If I try other Editor: Auto Indent preferences, (keep, brackets, advanced, full), all the four settings give:
I don't want this either, what I want is:
I tried many different settings that VS Code offers,
but I couldn't find something that does what I want to do exactly.
CLion provided such formatting, but its debugging is too slow so I'm switching to VS Code.
Is there such formatting option?
If not, how can I customize formatting?

Markdown code block highlight consistency - what is "s" alias

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.

Editor does not recognize some characters

When I open a cobol file in Notepad++ it looks normal. However, in Visual Studio Code it looks weird like it does not recognize the characters in it. How can I make it so that it looks normal in Visual Studio Code also.
Here is how it looks in both.
Notepad++
Visual Studio Code
It's probably saved in an encoding besides UTF-8. You can change the encoding with the "Change File Encoding" command, or by clicking on the encoding in the status bar. Or, try setting "files.autoGuessEncoding": true.
Put a call to the built-in input function
at the very bottom of the script in 3.X (in 2.X use the name raw_input instead). For example:
import sys # Load a library module
print(sys.platform)
input() # <== ADDED
input reads and returns the next line of standard input, waiting if there is none yet available. The net effect in this context will be to pause the script, thereby keeping the output window open until you press the Enter key

Set encoding permanently in Visual Studio Code

I am using Visual Studio Code to write a LaTeX file with the LaTeX Workspace plugin.
However everytime that I open VS Code it insists that the encoding of the TeX file is UTF-8 and makes all the special characters go bezerk, but for some reason TeX Live doesn't compile in that encoding even if I convert it. Since another person is using the file too and their editor is set in Windows 1252 encoding, I want to keep using that.
How to set a encoding to a file permantly (or to an extension) in VS Code?
There are language-specific configurations. CTRL-Shift-P and see "Preferences: Configure Language Specific Settings... However, I do not see a LaTex choice there. But you may because of the LaText Plugin. So you could do something like:
{
"[latex]": {
"files.encoding": "windows1252"
}
}
If you don't see one perhaps you could associate your file extension (.tex?) with one on the list and then the above setting?
I assume you have
{
"files.autoGuessEncoding": false
}
already set to false - the default. WTH, try "true".
And see Allow to set files.encoding as language specific setting for files on startup so the lanuage-specific setting should work better on start-up.
Your settings.json per user or per workspace can contain an encoding directive.
If you want Java files opened in UTF-8,
then the following has no effect
"files.encoding" : "utf8",
but this works
"[java]": {
"files.encoding": "utf8"
}
The existing answers show a possible solution for single files or file types. However, you can define the charset standard in VS Code by following this path:
File > Preferences > Settings > Encoding > Choose your option
This will define a character set as default.
VSCode set default file encoding
Sven Eschlbeck's answer illustrated:
The following page will be opened. There are many settings. To get to the desired item without scrolling through all entries, type "Encod" in the search box. Observe that the item "Files: Encoding" is presented to us. Now we can change the setting.
Tips to share with you: "GB18030" applies fairly well universally for source code files containing Chinese characters.
More tips:
The encoding being applied to the current file is shown in the status bar. Mouse right-click this to call up the options as shown.
Here, you can switch encoding ad-hoc.
Having autoGuessEncoding true in USER and autoGuessEncoding false, "files.encoding": "windows1250" in WorkSpace was still giving me windows1252.
I do not uderstand why User overchanged WorkSpace. I have to disable autoGuessEncoding also in USER to finally get "files.encoding": "windows1250" work everytime.
So you can face the same issue and this could help.