How to remove this gray line that causes text to wrap in VS Code? - visual-studio-code

I've recently noticed that when typing out long lines of code, they split into multiple lines after this threshold and it bothers me. enter image description here
Not sure if it was a formatting extension that I put on here years ago, but I couldn't seem to locate it in the settings.

The grey line isn't what causes the wrapping. You can apply settings to have the grey line and not have wrapping. They grey line is displayed according to the editor.ruler setting.
In general text editor terminology, this wrapping you are observing is called "soft wrapping" (when an editor wraps long lines in its rendering of the text, but doesn't actually insert line-break characters, which is called "hard wrapping").
By default, soft-wrapping can be toggled by Alt+z (The command palette command is named View: Toggle Word Wrap).
The default setting of soft wrapping for VS Code is configurable by the editor.wordWrap setting. It has several values it can take on:
"bounded": lines wrap at the minimum of viewport width and editor.wordWrapColumn,
"off": Lines will never wrap
"on": Lines will wrap at the viewport width
"wordWrapColumn": Lines will wrap at editor.wordWrapColumn
The word wrap column is configurable by the editor.wordWrapColumn setting. See also the editor.wrappingIndent and wrappingStrategy settings.

This is a setting called rulers. Go into Settings and search "rulers". Then you will be able to edit the settings.json file. Under "editor.rulers" remove all values in the array so that it is empty. That should solve it.

Related

Display larger indentation for files that are indented with just two spaces

I'm working on a project that is using 2 spaces as indentation.
I have a hard time reading code with such small indentation, so my question is:
Question: Can I make vscode show the two spaces as if they were wider (for example double the width)?
(I could of course solve it in a hackish way, by converting each file on checkout, and convert it back before i commit it, but that would be very tedious and error prone. I could also try to convince the project to convert the whole project to tabs, so that everyone can use their own preferred indentation. But I don't want to go into that discussion for every project I work on :) )
I have written the extension Indent Whitespace that decorates each space used in indentation with additional spaces (cursor will skip the decoration).
The decorated spaces are colored with a very transparent red.
With a setting you can change the number of spaces to add, default 1.
If you delete spaces with Delete it looks funny because the selection does not change, use the Arrow keys to update the decorations.
In a later version I will make the decoration color a setting, and also only update the decoration when the file changes (only important for large files, and fix the delete-update rendering).
I think you can't.
There is no such setting in VS Code. As of version 1.13, you can change the kerning, but this changes the spacing between all characters. You cannot do this only for a single character (or a set of characters).
The space width is a property of the font. Microsoft has a guideline that defines what is the ideal space size for a font. But this does not mean you cannot change it yourself when designing one. So I created a version of Roboto Mono which space character is 4x the original one.
This works on Notepad and MS Word, we can see the space is quite big. However, using the exact same font in VS Code, the space is still small, independently of the font being monospaced or not.
Illustration
Somehow, it looks like VS Code ignores space size in the font and decides by itself what is the best value.

How can I have a fixed screen so that when I code I don't have to keep scrolling right in VS code or keep having to indent? [duplicate]

I want to use full viewport while coding in VS Code. But the lines are not expanding when i expand my VS Code window.
Any Fix ?
The correct configuration to use:
In order to configure V.S. Code so that the lines of code in
your editor will only wrap at the end of the view port, and
never before, you need to assign the correct value to the
setting: editor.wordWrap
There are 4 different values that can be assigned to the
editor.wordWrap setting. There is one that I believe
is exactly what you are asking for, however; 2 of the other
three could work too, so I will list them all, and suggest
the one I think will work best for you. The following are
the only "out-of-the-box" line-wrapping configurations that
VSCode supports, and they are as follows:
01|   "editor.wordWrap": "off"_
— Assigning off to the wordWrap setting will make it
so that your editors lines will never auto-wrap. The only
way a line will ever be moved to the next line is if you add
a line break — by pressing the [ENTER] key. — and
proceed to continue typeing text on the next line. This way
could work for you, because you get 100% control over when
the lines break.
02|   "editor.wordWrap": "on"
Assigning on to the editor.wordWrap setting makes it
so that that the lines of code in your editor will wrap
exactly where the viewport ends. No matter how big, or how
small the editor's viewport width is, the lines always
extend the entirety of the viewport, and never before.
NOTE: "on" sounds to me like what you were asking for
in your question
03|   "editor.wordWrap": "wordWrapColumn"
When you assign wordWrapColumn   —to—   "editor.wordWrap" the lines of code inside your editors view-port will wrap at what ever you set the setting editor.wordWrapColumn to. To be more specific, I'll give you an example.
if you configure wordWrapColumn so that it looks like the code-snippet below:
"editor.wordWrapColumn": 80
...then your lines will all wrap at 80.
This is by far the most popular configuration, as it is frequently coupled with 3rd party formatters, and linters, such as ESLint & Prettier. Prettier's printWidth setting, coupled with "editor.wordWrap": "wordWrapColumn", is an extremely reliable and consistent configuration.
4| "editor.wordWrap": "bounded"
— Last is "bounded", bounded is a mix between on, and print width. In a nutshell, lines will wrap if either of two conditions are true.
- First lines will wrap at what ever "editor.wordWrapColumn" is set to, just like the configuration example #3.
- Secondly, lines will wrap at the end of the view port.
To reiterate through what I just typed, lines wrap at _"editor.wordWrapColumn"'_s value, unless the view-port is smaller than the value of "editor.wordWrapColumn", in that case lines wrap at the view-port.
That's all...
You can add any extension in you VS code such as Beautify or Prettier. Or if you want to format the document you can simply use shortcut Shift+Alt+F.
If you want to merge multiline code into single.Follow the steps
1.Select all line you want to merge in single.
2.Press F1 and search for join lines.
3.Select join lines and press enter.
You can also create a keyboard shortcut for this command editor.action.joinLines
"editor.mouseWheelZoom": true
Adding this setting to your settings.json will enable zooming in when holding CTRL and scrolling. After you save settings.json with this setting, you can hold the ctrl key and scroll with your mouse or trackpad to zoom in which will make your code cover the full screen. If you want more focus, you can enter Zen Mode. It is a nice feature built into Visual Studio Code, which helps you to focus more on your code than the activity bar or other files. You can toggle zen mode with shortcut keys CTRL + K Z, Command palette, or View menu.

Make spaces act and look like tabs in VS Code

When writing a source file in VS Code that is styled with spaces of a specific width (maybe determined by the .editorconfig file), how can I force VS Code to treat the spaces like tabs without reformatting the file?
For example, the indent width may be 4 spaces, so rather than displaying 4 spaces in my editor, I'd rather see one tab space character with a width of 4 spaces.
The selection aspect of space-tabulated code is supported with VSCode 1.52 (Nov. 2020) and:
Sticky Tab Stops when indenting with Spaces
If you prefer to indent your code with spaces, there is a new setting called editor.stickyTabStops, which makes VS Code treat cursor movements in leading spaces similar to tabs.
Appearance
You said vscode is:
displaying 4 spaces in my editor
I assume that means you're getting those little Interpunct dot characters coming up like this ····
If you want those to go away, so they appear more consistent with tabs, go into VScode settings (JSON) and enter the following:
"editor.renderWhitespace": "selection"
Assuming everything else is default, both tabs and spaces should be rendered as regular whitespace. But that alone it doesn't really help, because it doesn't allow you to distinguish nested structures i.e. you can't tell how many levels of indentation you're at.
To fix that, there's 2 things.
(minimum) Set indent guides explicitly in your user settings, this will render vertical lines at each indentation level, no matter if the file is using tabs or spaces:
"editor.renderIndentGuides": true
(optional extra) If you want to take it further, there are a few extensions you can try, but the one i recommend is indent-rainbow. There are lots of options for it, but i have mine config'd so after a certain level of indentation it becomes more obnoxious, because i treat it as a code smell i.e. i like to minimize how much i nest if possible.
The end result of doing all this is that tabs and spaces are rendered exactly the same way, and you can't tell the difference unless you have part of your code highlighted:
Behavior
To make the behavior of indentation more consistent, the following should be in your settings if it's not already applied by default:
"editor.detectIndentation": true,
"editor.insertSpaces": true,
"editor.useTabStops": true
As for this:
source file in VS Code that is styled with spaces of a specific width (maybe determined by the .editorconfig file)
I don't think this is possible, or at least not natively. You may be able to find/write an extension that can do detection based on tabsize since there is in fact a property called:
"editor.tabSize": 4,
Not sure if this will help, but you can do selective setting overrides based on filetype, for example:
"[yaml]": {
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.autoIndent": "advanced"
}

Auto wordWrap to the window VSC

I would like to auto word wrap all files to the window. In sublime this is simple with auto however, in VSC I have three options:
editor.wordWrap
editor.wordWrapColumn
editor.wrappingIndent
My issue is that no matter what settings I use I am unable to wrap the text to the window. There is about a 3 inch gap on 15in monitor from where the text ends to the edge of the window. I want to be able to move the window by snapping to any edge and my words wrap automatically no matter what size the window is - if you have used sublime you will understand this situation.
"word_wrap": "auto",
"wrap_width": 0
Thanks for your help. I'm guessing this is a simple step but I am very new to VSC.
With the following settings, the VSCode should always wrap at the Window's edge:
"editor.wordWrap": "bounded",
"editor.wordWrapColumn": 9999
"bounded" is documented as:
wrap at minimum of viewport and editor.wordWrapColumn
Since wordWrapColumn is still respected in bounded mode, and the default of 80 is rather low, you basically need to set that to something "unlimited" to get the desired behavior.

How to add padding to symbol text in Visio 2013?

In Visio 2013, I have a connector that is in a container that has a gray background color. I successfully changed the background color of the text block by following these steps:
Double-click the connector
Expand the font options by clicking on the icon in the lower-right portion of the 'Home > Font' ribbon area
Click on 'Text Block' tab in the 'Text' dialog
Select 'Solid color' and choose the background color that matches the gray container background color
That works as expected - my text background color is no longer the default white; it now matches the background color of the container.
However, I want to add spacing to the left and right of the text. I tried increasing the margins in the same 'Text Block' tab of the 'Text' dialog mentioned above. This increased the margins but did not extend the background color of the text. A also tried manually adding spaces to the left and right of the text. The leading spaces worked, but the trailing spaces where truncated. Is there any way to add left and right padding to the text (similar to css padding)?
Modifying the text block location/size may give you what you want, combined with text margins.
To modify the text block location, you have to click the text block tool, which is on a dropdown with the text tool (at least in Visio 2003).
I know this is an old question, but I had the same question myself and wasn't able to (quickly) find an answer out there either. I finally hit upon a trick that'll get the result we're looking for:
Instead of spaces, add leading and trailing characters to the longest line in the text box. (I use ".")
Change the color of ONLY those added characters so it matches the text box's background.
The text box's background reaches to the furthest edge of the text within, and we're just using that to get what we want. Since it's just moving the edge indirectly, I consider it a "trick" that we can use instead of a "fix".
Quick list of Cons:
The text box background color has to be solid, or close to it.
The "invisible" text will still exist, so it'll show up in a copy/paste of the text.
Similarly, it may make Searching/CTRL+F for things within the document/file more difficult.
You can use No-Break Space. Insert it from Insert > Symbol.