Visual Studio For Mac Format Code



  1. To automatically format your code in the current source code window, use Cmd+Alt+L (on Mac) or Ctrl+Alt+L (on Windows and Linux). Android Studio and IntelliJ also provides a check box named Format code on save on the Flutter page in Preferences (on Mac) or Settings (on Windows and Linux) which will format the current file automatically when you.
  2. Right click on that solution node and you will get 'Code Formatter Format Code' option on the menu as shown below. In Option 3 and 4, all the.cs file present within the Project or solution respectively will get formatted automatically. Settings for tool can be accessed from Visual Studio options screen as shown below. General Settings.

This topic applies to Visual Studio on Windows. For Visual Studio for Mac. Format Document. Toggle between the code editor window and the Peek Definition window.

Lint (code quality), Format and Auto-fix your groovy files and Jenkinsfile

Visual Studio Code extension embedding npm-groovy-lint, itself embedding CodeNarc

  • You can configure the rules by defining a .groovylintrc.json file
  • If you use CI, you can integrate Mega-Linter in your workflow, to make sure all your sources (groovy and other) are clean

Features

CommandDescriptionAccess
Analyze codeLint the code of the current fileCtrl+Shit+F9
Contextual
Status bar
Commands
FormatFormat the code of the current fileShift+Alt+F
Contextual
Commands
Fix all auto-fixable problemsFix the code of the current fileContextual
Commands
Lint folderLint all applicable files of a folderContextual
Fix single errorApply quick fix for a single problemQuick Fix
Diagnostic
Fix rule in entire fileApply quick fix for all problems related to the same rule in the current fileQuick Fix
Diagnostic
Disable rule for this lineDisable rule only for current lineQuick Fix
Diagnostic
Disable rule for this entire fileDisable rule in the entire fileQuick Fix
Diagnostic
Disable rule for this entire projectUpdates configuration file
(usually .groovylintrc.js in root folder) to disable this rule)
Quick Fix
Diagnostic
  • Contextual: right click in source code or on folder
  • Commands: Ctrl+Shift+P then type command name
  • Status bar: GroovyLint status item at the bottom right
  • Quick Fix: Hover an underlined part of the code after a lint, click Quick Fix then select action to perform
  • Diagnostic: Right click on a diagnostic in Problems section

Extension Settings

ParameterDescriptionDefault
groovyLint.enableControls whether GroovyLint is enabled or nottrue
groovyLint.lint.triggerRun the linter on save (onSave), on type (onType) , or on user requestonSave
groovyLint.format.enableControls whether the groovy formatter is enabled or nottrue
groovyLint.fix.enableRun the auto-fixer on save (onSave), on type (onType) , or on user requesttrue
groovyLint.fix.triggerRun the fixer on save (onSave), or on user requestuser
groovyLint.basic.loglevelLinting error level (error, warning,info)info
groovyLint.basic.verboseTurn on to have verbose logsfalse
groovyLint.basic.configNPM groovy lint configuration file.groovylintrc.json
groovyLint.debug.enableDisplay more logs in VsCode Output panel (select 'GroovyLint') for issue investigationfalse
groovyLint.java.executableOverride java executable to use
Example: C:Program FilesJavajdk1.8.0_144binjava.exe
java
groovyLint.java.optionsOverride java options to use'-Xms256m,-Xmx2048m'
groovyLint.insight.enableAllow to send anonymous usage statistics used only to improve the tool (we will of course never send your code)true

Troubleshooting

  • Node.js version 12 or higher Mstsc exe download. is required to run this extension. If you can't upgrade, you can use nvm to have different node versions on your computer

  • Java version 8 or higher is required to run this extension

  • As CodeNarc is run in background with java/groovy, performances could be improved on large files (do not hesitate to provide advices !)But do not worry, as the groovy linting is provided by a background local server, your VsCode won't be slowed.

Contribute

Contributions are very welcome on :

  • NPM Groovy Lint (linter called by this extension)

Please follow Contribution instructions

Special Thanks

  • yuvmel, for his great support on #18 that allowed VsCode Groovy Lint to work much better on Mac, Linux, and with other diagnostic extensions

Release Notes

[1.3.0] 2020-11-15

  • Upgrade to npm-groovy-lint v8.0.0
    • Upgrade to CodeNarc 2.0.0
    • Improve performances
    • Fix bugs

[1.2.7] 2020-09-04

  • Upgrade to npm-groovy-lint v7.5.4

[1.2.6] 2020-09-02

  • Upgrade to npm-groovy-lint v7.5.2
  • Fix crash when empty groovy file
  • Fix crash when non-sense groovy file

[1.2.3] 2020-08-29

  • Fix bug on Windows when username contains space(s)

[1.2.2] 2020-08-21

  • Allow user to hide future npm-groovy-lint error messages
  • Manage correctly user choice Never for tabs auto-replacement by spaces
  • Upgrade to npm-groovy-lint v7.4.0

[1.2.0] 2020-08-15

  • Upgrade to npm-groovy-lint v7.3.0
    • Allow to link to CodeNarc RuleSet files from .groovylintrc.json, using property 'codenarcRulesets'. Warning: doing so means that all other properties of config file will be ignored.

[1.1.1] 2020-08-11

  • Upgrade to npm-groovy-lint v7.2.0
    • Upgradejava-caller to v2.0.0 : better performances

[1.1.0] 2020-08-10

  • Upgrade to npm-groovy-lint v7.1.0
    • Externalize JavaCaller class into a separate package java-caller and use it

PREVIOUS VERSIONS

See complete CHANGELOG

My last few articles have focused on using Visual Studio Code to build a series of scripts to help manage Analysis Services data models. As part of this work, I’ve found Visual Studio Code to be extremely helpful in other ways too, such as a very powerful text editor with many features you may find in other advanced text editing tools. So much so, I now use Visual Studio Code as the primary tool I use when working with text files – regardless if any code is involved. Downloadsfree .flp projects!.

VisualStudio

One task in particular I find helpful is to auto format JSON text to either make it more readable, or to identify issues with the structure of the JSON itself – such as missing brackets etc.

Here is a simple example showing how you can create an empty file and paste in some JSON text. Depending on the JSON, the file will auto detect you are working with JSON data, or you need to set the language using the status bar in the bottom right-hand corner.

The animation also shows how you can use the tool to help you fix issues to do with how well-formed the the JSON code is. Free download xexmenu 1.2.

Visual Studio For Mac Format Code Online

The key-map to auto-format the selected JSON is ALT-SHIFT-F.

This is the same key-map to auto-format other languages too, so I often find myself doing CTRL-A (for select all text) followed by ALT-SHIFT-F to fix my messy C# code after a series of cut and paste operations.

Another Visual Studio Code tip

Visual Studio For Mac Format Code

If you find you enjoy using Visual Studio Code to work with text documents, I recommend you ensure the following settings are enabled when you install (or re-install) Visual Studio Code. Once you enabled these check-boxes, you get the option to “Open in Code” when right-clicking a file or folder in Windows Explorer. Essential stuff!

Visual Studio For Mac Tutorial

Article Rating