Why is my Dart code auto-moved to a different line, when I Ctrl+S? - flutter

What happened is that when I move my codes to different lines, and when I CTRL+S, the code automatically get moved to a different line.
What setting in VS Code is this?

That's because you have format on save.
You need to go to VS Code settings and search formatOnSave and turn it off

check if the "auto format on save" option is on: VSCode: How do you autoformat on save?
you can also go into the dart plugin's preferences in vscode and change the line length at which formatting the code will auto-wrap it. You can make it however long you want. Just go into settings and search "Dart: Line Length"

For me, I went to the dart extension setting, there is an option of Dart: Enable SDK Formatter. It should be the problem I guess because when I disabled it, everything started working fine.
We can directly search for Dart: Enable SDK Formatter in VS Code settings.

Related

Is there Partial Formatting for Flutter&Dart in Visual Studio Code?

I tend to CTRL+S my code quite often so Dart SDK formatter automatically formats the .dart file completely, from top to bottom. I know it is easy to turn this off by simply going to settings.json file of VSCode and adding "editor.formatOnSave": false,
When using Android Studio, I tend to turn this feature off and do partial formatting where I choose which part of the code I want formatted and hit the keys, telling IDE to format it which isCTRL+ALT+L by default.
Now I wonder if I can do partial formatting in Visual Studio Code. I don't want to auto-format my dart code and I don't want to format the whole dart file in VS Code, what do I do, can I do it?
No, there is no partial formatting as of right now.

How to prevent Visual Studio Code Flutter/Dart Editor from formatting new line/wrapping code?

I recently started working on Flutter/Dart, I like the flutter autoformatting on-save, but one thing might or might not be related is the code wrapping for long code even if code is still fitting my 4k editor window.
Is there a way to prevent new line but keep the comma auto format?
Thanks
Follow the instructions below:
Open Settings.
Expand Extensions and click Dart & Flutter on the left.
Find Dart: Line Length.
Change it to the value you want.

How to disable "Run|Debug" line in vscode?

I am currently using Flutter with Dart. How do I permanently disable this annoying "Run|Debug" line in vscode?
That Run | Debug is not built-in to vscode. It must be contributed by one of your extensions. These seem like likely culprits:
Dart: Show Main Code Lens
// Whether to show CodeLens actions in the editor for quick running/debugging scripts with main functions.
Dart: Show Test Code Lens
// Whether to show CodeLens actions in the editor for quick running/debugging tests.
In case people get here because there is a Debug or Run in their package.json, that is a separate issue and answer, see https://stackoverflow.com/questions/62358131/how-to-disable-debug-from-showing-in-package-json/62368407?r=SearchResults&s=1|57.9327#62368407
Just disable Enable Code Lens in jest plugin.
It's very annoying! When you write test code, small Debug text shows on top of a test (above it method) when it fails.
During programming, it constantly shows and hides, causing lines of code move up and down a bit. It's terrible experience. Fortunately, easy to disable.
After disabling it, we still have test status feedback:
In VSC settings, search for "Pester Code Lens".
You can disable the first option.
Disable Pester Code Lens
Add this line to your settings:
"editor.codeLens": false,
Or do this in settings:
For Java Extension paste this in your settings.json file
"java.debug.settings.enableRunDebugCodeLens": false
you just open your vs Code Setting -> Text Editor -> Code Lean [Check mark this Box]

How can I get rid of visual studio code's auto formatting?

How can I block visual studio code from auto formatting on save?
It causes chaos to the git commit!
The blanks which are auto generated by this software, which have nothing to do with the function improvements, are messed up with the real useful code.
How can I get rid of this auto formatting?
Go to Settings and search 'format'. There's an option there called "Editor: Format On Save". Turn this off, and it should disable the auto-formatting.

How to set up a minimap in VS Code?

I want to get an overview of my code and would like to use a minimap in VS Code.
I did not find an option to set this up in the menus. I am using VS Code 1.9.
Starting with version 1.10 (Feb 2017) vscode supports minimaps.
You can switch this function on via the preferences. Just follow these steps:
open vscode
File
Preferences
Settings
On the right pane you see your own custom settings. There you can add the following settings:
// Controls if the minimap is shown
"editor.minimap.enabled": true,
If this is the first setting you need to surround this with curly brackets and remove the tailing comme. If you have already one or more please keep in mind this is JSON so you need to separate key:values with a comma.
Adding the following to settings.json will also highlight where you are on the map:
"editor.minimap.showSlider": "always"
Additionally, to render blocks instead of characters for better visualization in the Minimap:
"editor.minimap.renderCharacters":false
You have to update to version 1.10+ and add "editor.minimap.enabled": true to your user or workspace settings, which can be opened with Ctrl+,.
Since the questions is "how to configure it" I will give what I've found is the most useful configuration of the minimap feature.
This is how it looks in my editor:
This is effectively about 1/3 height and only the first 40 columns. But still just readable. It makes it so I can quickly grab the minimap slider and scrub through a file.
Here is my minimap config:
In current VS Code versions, you can simply enable and disable minimap under view->Show minimap.This is reference from Visual studio code version 1.55.2. This way we don't need to edit json settings file.