Disable word wrap in VS Code - visual-studio-code

I have the following settings in VS code to disable word wrap
"editor.wordWrap": "off",
"editor.wordWrapColumn": -1
Word wrap is still not turned off. This makes VS Code really unfriendly to use on my laptop with a small screen.
Is there some additional setting I can use?
I am on 1.17.1.

Are you using markdown? vscode changes some default settings:
"[markdown]": {
"editor.wordWrap": "off"
}

On version 1.17.1 try changing default settings (not overriding with user settings) to:
"editor.wordWrap": "off",
"editor.wordWrapColumn": 80,
That works for me. And you can also edit the user settings (via Code or directly editing settings.json file on AppData\Roaming\Code\User (at my computer) by just adding the wordWrap line.
After changing settings always close and reopen both VS Code and the file (as it saves it opened).

If you are dealing with a file that has very long lines, this could be the issue you are facing.
https://github.com/microsoft/vscode/issues/21124
It seems it is made that way by design to prevent slow load times. It can be manually overridden with ALT + Z shortcut while the file is opened. After that, it reverts to the old setting and you have to do it again.

Related

Change line guide frequency in vscode

I have some dart code I am looking at in vscode.
The dart code uses 4 space indentation (literal 4 space, opposed to tabs).
When I view the code in vscode, it is putting line guides every two spaces. This doesn't make any sense since the indentation only occurs every 4 spaces. So it is essentially showing line guides to no where.
Observe the following screenshot
How can I fix this???
Go to Files > preferences > settings > select:Editor-Tab size You can change tab-size there.
Note: If you are using Eslint or Prettier make sure your editor settings are not overriding
The problem is that editor.tabsize setting is being overridden by language specific settings.
To fix I put the following in my user settings.json file...
"[dart]": {
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.detectIndentation": false
},

How do I turn VSCode Word Wrap off as default?

VS Code Version 1.36.1 for Mac.
Every time when I open VSCode, the word wrap is on. I have to ⌥+Z to turn it off. Whenever I close VSCode and reopen it, I have to do this again.
While in the Settings, either in User or Workspace, Editor: Word Wrap is off.
What am I doing it wrong? How to fix it?
I still encountered this issue in v1.64.2 on MacOS. I found a workaround in this Github thread answer. Setting or adding accessibility option to "on" worked for me.
"editor.accessibilitySupport": "on"
Try checking your configuration file.
Windows: %APPDATA%\Code\User\settings.json
Mac: $HOME/Library/Application Support/Code/User/settings.json
Linux: $HOME/.config/Code/User/settings.json
And remove the parameter "editor.wordWrap": "on" or change it to "editor.wordWrap": "off".
There is a fringe case where explicit word-wrap: off doesn't work. All you have to do to fix it is this:
Alt + z / Option + z
Do this in the editor that is wrapping lines.
More info:
This occurs most commonly when you paste a long line from one file to another.
Pressing Alt + z will force the viewport to update the horizontal virtualization (or lack thereof). You can read more about this bug-that's-not-a-bug here: https://github.com/microsoft/vscode/issues/21124#issuecomment-308644030

Disable vscode clear/remove not used code when save file

When I save file, VSCode auto cleans the not used code, How to Disable it? I want to make VSCode not to delete any line of my code.
Go to Visual Studio Code's settings page in JSON format then remove the line
"source.fixAll": true,
this line you will find inside of this object
"editor.codeActionsOnSave": {
},
After finding and testing, it can be configured at Workspace Settings > Go configurartion, override "go.formatOnSave": false, on the right side, disable formatting then the code will not be auto cleaned.
EDIT: Later then I meet this issue .

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.

Prevent Visual Studio Code from replacing tabs with spaces on save

My problem is not present while editing a file, like here: Spaces to tabs in Visual Studio Code
VSC converts all tabs to spaces when I save the file. How could I stop that stupid behavior?
This are my actual user settings:
{
"editor.insertSpaces": false,
"editor.detectIndentation": false
}
Further informations:
"editor.formatOnSave": false
Wish I understood more about what's happening here, but in my case, what finally worked (for now) was unchecking "Editor: Insert Spaces" in my user prefs. Without this, disabling Save on Format didn't seem to help. ¯\_(ツ)_/¯
I had an extension which overrides the default behaviour:
https://marketplace.visualstudio.com/items?itemName=lonefy.vscode-JS-CSS-HTML-formatter