Visual Studio Code

From Torben's Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

settings.json

   // VS Code Core
   "diffEditor.ignoreTrimWhitespace": false,
   // "editor.fontSize": 18,
   "editor.accessibilitySupport": "off",
   "editor.formatOnSave": true,
   "editor.minimap.enabled": false,
   "editor.suggestSelection": "first",
   "editor.wordWrap": "on",
   "files.eol": "\n",
   "files.insertFinalNewline": true,
   "files.trimTrailingWhitespace": true,
   "files.exclude": {
       "**/node_modules": true,
   },    "outline.showVariables": false,
   "security.workspace.trust.untrustedFiles": "open",
   "telemetry.telemetryLevel": "off",
   "update.showReleaseNotes": false,
   "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
   "window.zoomLevel": 1,
   "workbench.startupEditor": "none",

Extensions

Arduiono

settings.json

   // Arduino / C
   "arduino.ignoreBoards": [
       "Adafruit HUZZAH ESP8266"
   ],
   //    "C_Cpp.updateChannel": "Insiders",
   "[c]": {
       "editor.wordBasedSuggestions": false,
       "editor.suggest.insertMode": "replace",
       "editor.semanticHighlighting.enabled": true,
       "editor.quickSuggestions": {
           "comments": "on",
           "strings": "on",
           "other": "on"
       }
   },

Clipboard History

CSpell - Code Spell Checker

settings.json

   // cSpell
   "cSpell.language": "en-US,de-DE",
   "cSpell.userWords": [
       "Menke",
       "Torben"
   ],

and
cspell.json (in project dir)

{
  "useGitignore": true,
  "dictionaries": [
    "cspell-words"
  ],
  "dictionaryDefinitions": [
    {
      "name": "cspell-words",
      "path": "cspell-words.txt",
      "addWords": true
    }
  ],
  "language": "en-US, de-DE",
  "ignorePaths": [
    "node_modules/**",
    "src/assets/i18n/**",
    "*.svg"
  ]
}

cspell-words.txt (configured above)

Torben
Menke
!forbiddenword

comments:

ignoreWords -> forbitten words to allow
dictionaryDefinitions -> custom wordlist/dictionary
ignoreRegExpList -> code blocks to ignore

ignore specific lines. Inside source code files use

// cspell:disable-line -- disables checking for the current line.
// cspell:disable-next-line -- disables checking till the end of the next line.

Check for unknown words in all files

cspell --words-only --unique "**/*.{txt,md,html,js,ts,json,yml,py}" > cspell-unknown-words.txt

Draw.io

Excel Viewer

Git

settings.json

   // Git 
   "git.autofetch": true,
   "git.confirmSync": false,
   "git.enableSmartCommit": true,

Gnuplot

HTML

settings.json

   // HTML
   "html.format.wrapLineLength": 0,
   "html.format.maxPreserveNewLines": 2,
   "html.format.preserveNewLines": false,
   "html.format.extraLiners": "head, body, /html, p, h1, h2, h3, h4, h5, h6",

JavaScript and Vue

see https://vueschool.io/articles/vuejs-tutorials/eslint-and-prettier-with-vite-and-vue-js-3/

Vue.js

settings.json

 //
 // JSON & YAML
 //
 "[json]": {
   "editor.defaultFormatter": "esbenp.prettier-vscode"
 },
 "[jsonc]": {
   "editor.defaultFormatter": "esbenp.prettier-vscode"
 },
 "[yaml]": {
   "editor.defaultFormatter": "esbenp.prettier-vscode"
 },
 //
 // JavaScript & Vue
 //
 "[javascript]": {
   "editor.codeActionsOnSave": [
     "source.formatDocument",
     "source.fixAll.eslint"
   ],
   "editor.defaultFormatter": "esbenp.prettier-vscode",
   // runs with "source.formatDocument"
   "editor.formatOnSave": true
 },
 "[vue]": {
   "editor.codeActionsOnSave": [
     "source.formatDocument",
     "source.fixAll.eslint"
   ],
   "editor.defaultFormatter": "esbenp.prettier-vscode",
   // runs with "source.formatDocument"
   "editor.formatOnSave": true
 },
 // Prettier settings - runs with "source.formatDocument"
 "prettier.enable": true,
 "prettier.enableDebugLogs": true,
 "prettier.trailingComma": "all",
 // ESLint settings - runs with "source.fixAll.eslint"
 "eslint.debug": false,
 "eslint.format.enable": true,
 "eslint.probe": ["javascript", "typescript", "vue", "html"],
 "eslint.validate": ["javascript", "typescript", "vue", "html"],

create package.json

npm init

install packages

npm install --save-dev eslint
npm install --save-dev eslint-config-google
npm install --save-dev prettier
npm install --save-dev eslint-config-prettier

create .eslintrc.json

npm init @eslint/config

.eslint.js

module.exports = {
  env: {
    browser: true,
    es2021: true,
  },
  extends: [
    "google",
    "plugin:vue/vue3-recommended",
    "plugin:vitest/recommended",
    "prettier", // as last one
  ],
  plugins: ["vitest"],
  rules: {
    // quotes: ["error", "double"],
    "vue/valid-attribute-name": "error",
    "vitest/max-nested-describe": [
      "error",
      {
        max: 3,
      },
    ],
  },
};

.prettierrc

{
  "arrowParens": "avoid",
  "endOfLine": "lf",
  "htmlWhitespaceSensitivity": "css",
  "printWidth": 80,
  "semi": true,
  "singleQuote": false,
  "tabWidth": 2,
  "trailingComma": "all",
  "vueIndentScriptAndStyle": false
}

LaTeX

settings.json

   // LaTeX
   "latex-workshop.latex.autoBuild.run": "never",
   "settingsSync.ignoredSettings": [],
   "[latex]": {
       "editor.autoIndent": "none",
       "editor.formatOnSave": false
       // "auto-format": false
   },

Markdown

settings.json

   "[markdown]": {
       "editor.formatOnSave": true,
       "editor.formatOnPaste": true,
       "editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
   },

Perl

Old:

  • Perl Toolbox (for coding style check) (requires perlcritic])
  • Perl (requires CPAN Perl::Tidy and ctags
  • Perl Debug (requires CPAN PadWalker)

Requirements

  • cpan install Perl::Tidy
  • cpan install Perl::Critic
  • ctags

settings.json

   // Perl
   "perltidy.additionalArguments": [ // see http://perltidy.sourceforge.net/perltidy.html
       "--perl-best-practices", // -pbp abbreviation for the parameters in the book Perl Best Practices by Damian Conway
       "--blank-lines-before-subs=2", // -blbs
       "--closing-side-comments", // adds "## end sub subname etc"
       "--indent-columns=2", // -ic does not work in vis.stutio code , but editor.tabSize does
       "--noblanks-before-comments", // -nbbc , opposite: --blanks-before-comments=2 / -bbc
       // "--maximum-line-length=0", // -l , 0 = infinite
       // "--standard-output", // -so
       // "--quiet", // -q Deactivate error messages and syntax checking (for running under an editor)
       // //
       // "--add-whitespace", // -aws add white spaces, use -naws if you do not want any whitespace added, but are willing to have some whitespace deleted
       // "--brace-tightness=0", // -bt braces thickness
       // "--cuddled-else", // -ce
       // "--delete-old-whitespace", // -dws default
       // "--ignore-side-comment-lengths", // comments are allowed to be longer than the lines of code
       // "--keep-old-blank-lines=1", //-kbl, 0=ignore, 1=stable, 2=keep
       // "--maximum-consecutive-blank-lines=1", // -mbl
       // "--nohanging-side-comments",
       // "--opening-brace-always-on-right", // -bar
       // "--paren-tightness=0", // -pt parentheses thickness
       // "--square-bracket-tightness=0", // -sbt square brackets thickness
       // // "--nohanging-side-comments",
   ],
   "perl-toolbox.lint.excludedPolicies": [
       "ErrorHandling::RequireCarping", // die used instead of croak
       "InputOutput::RequireCheckedSyscalls", // Lint: BRUTAL: Return value of flagged function ignored - print
       "NamingConventions::Capitalization", // var. names all capital or all lower case 
       "ProhibitEmptyQuotes", // don't complain if using $s = 
       "ProhibitEnumeratedClasses", // don't complain about [a-z]
       "ProhibitEscapedMetacharacters", // don't complain about \d in reg exp / Use character classes for literal metachars instead of escapes
       "ProhibitMagicNumbers", // don't complain $n = 14
       "ProhibitManyArgs", // don't care how many arguments a function has
       "ProhibitNoisyQuotes", // don't complain if using 1 char strings: $s = 'a'
       "ProhibitParensWithBuiltins", // don't complain if using () for buildin functions like open
       "ProhibitPostfixControls", // don't complain for $n ++ if <something>
       "ProhibitPunctuationVars", // don't complain if using $!
       "ProhibitUnusualDelimiters", // don't complain about m!^(https?)://!
       "ProhibitUselessTopic", // don't complain about use of $_
       "RequireDotMatchAnything", // don't complain Regular expression without "/s" flag
       "RequireExplicitPackage", // don't require package as first line 
       "RequireExtendedFormatting", // don't complain Regular expression without "/x" flag
       "RequireLineBoundaryMatching", // don't complain Regular expression without "/s" flag
       "RequireNumberSeparators", // don't require 141_234_397.0145 instead of 141234397.0145 .
       "RequireTidyCode", // don't complain on first line if not all of Perl::Tidy is met
       "RequireVersionVar", // don't complain on No package-scoped "$VERSION" variable found 
       "ValuesAndExpressions::ProhibitInterpolationOfLiterals", // check use of ' vs "
   ],
   // "perl.ctagsPath": "c:\\Users\\t\\Progs\\ctags\\ctags.exe",

PHP

settings.json

   // PHP
   "intelephense.environment.phpVersion": "7.4.30",

Python

see Python#Editor:_Visual_Studio_Code

Remote - SSH

  • Connecte to remote machine via Remote - SSH
  • F1
  • "Remote SSH: Connect to Host"
  • user@server.com

Shell Format

Text Linting