How to avoid displaying the leading and trailing spaces in vs code - visual-studio-code

Attached is the picture where the leading spaces are visible higlighted with red color. How to avoid displaying these whitespaces ? I have tried delete whitespaces extension. On saving the file they again come back.

What you see is changes since the last commit if your code is under version control system like git. Probably when you save your file auto code formatter restore this space according to your code format settings. You can try to disable "Format on save" option in VSCode settings.

Related

Fix issue with VS Code: Border around all whitespaces in lines of code

All my whitespaces in VS code where code is written are being highlighted and I cant seem to understand where to change these settings.
In settings (open Command Palette CTRL+SHIFT+P and search for settings) menu search for Editor: Render Whitespace it is probably set to all instead of default selection. But i honestly have no idea why it is render with boxes and not dots or arrows, maybe it can be customized by using custom themes.
It was probably because of the theme the source was using from where I copied the source code. Replaced all these spaces with regular whitespace and now it's working fine.

Visual studio code editor deleting tabs after delay

Anyone knows how to disable automatic removing tabs on new line after delay? Like you can see on picture below, VS Code deletes tabs on new line everytime when I don't start typing very fast.
Something similar is situation when I'm writing comment, create space and wait for a while. VS Code will delete my last space.
I fixed this by turning off the setting "files.autoSave", (I didn't want that in any case.) or disable your formatting tool. (most likely cause)
My problem was that I had a formatting tool run on save, which was removing excess white space and therefore squashing my tabs during editing. Looks like you have the same problem to me.
You can affect a delay if you want to use the auto-save feature by setting auto save to afterDelay and setting the delay to your liking

Use tab indentation for one-off file when Eclipse is configured to use spaces indentation without chanding preferences

I'm using Eclipse for PHP Developers (PDT). Normally I use spaces instead of tab characters for indentation. However, I'm editing someone else's file who indents using tabs and I want to preserve indentation style while editing their file. This is turning out to be difficult because whenever I press the Tab key it inserts spaces. I don't want to change my configuration to use spaces instead of tabs as I'll have to remember change it back. Is there a way I can insert a literal tab character?
I've tried copying a existing tab character in the file yet past results in spaces being inserted!
While I haven't found a way of inserting a literal tab character, with the AnyEdit Tools add-on installed I've found this simple procedure works for me:
Edit the file ignore the whitespace inconsitencies.
Once finished edits, right-click and select Convert > Spaces to Tabs.
Should work the other way round if one was normally used to Tab indentation.

VSCODE inserting spaces via format on save

VSCODE seems to be inserting spaces everywhere in my html code. I checked the settings and it's the following which is causing it: "editor.formatOnSave": true
Example:
How do I configure this to stop inserting spaces?
I have the following set :
"editor.formatOnSave": false,
"editor.insertSpaces": false
Now it is not inserting spaces. Hope it helps
Mine was caused by an extension JS/ CSS formatter, after i uninstalled and restart vscode works great.
After spending hours wondering why my django static links are broken smh
When saving, Visual Studio inserted a lot of spaces. This happened after an update of Visual Studio. This problem was because of an extension called Bracket Pair Colorizer. What I did was, uninstall and reinstall, and that solved the problem. I suggest to check all your extensions. It could be one of them.
I disabled the option of HTML formatting and no more space when saving files.
Settings > Extensions > HTML > Format: Enable
Enable/disable default HTML formatter.
What was the case with me is that I had the option Editor: Format on save mode to be set to file, this in combination with format on save would mean VS Code will try to format the entire file, resulting in spaces as defined in the formatter.
Change this to be modifictions, and VS Code will only save the lines you have made changes in.

detect white space difference between two files

We are using git. I am using eclipse. Some of the committers may not be using eclipse. Here's what is happening.
I make a small change in an existing file (properties/xml/java) and save it and commit it.
gitk (without ignore space change) and eclipse thinks the whole file changed. The commit shows ## -1,354 +1,354 ## which means the entire file changed.
When I check for code change difference, with ignore white space, then I can see the text difference. But I don't know what white space change is causing this.
How do I detect what white space difference is there between two files? It could be new line character, carriage return, tab, or something else.
This is how eclipse compare editor works. Unlike other file compare tools(kdiff3 or winmerge or Beyond compare) it shows entire file instead of showing only the difference.
But you can jump to individual changes by clicking on the change book markers as highlighted below.
You can integrate other compare tools(Ex: Beyond compare, winmerge) in eclipse.
Refer these links
Beyond Compare with git
Winmerge with git
Edit:
White space changes are shown in GREY background color