What is this marked number next to the file name in Visual Studio Code? - visual-studio-code

I know the meaning of M as "modified" on the right side of the file name.
But what is that number 4 next to the M ?
Is there a name for these marks?
Any docs of this will helpful!

That is the number of linting errors and warnings currently in the file.
To see the actual errors and their details, open the Problems panel, which by default is at the bottom part of the editor. (If it's not shown, open it by going to the menu View > Problems).

As #Goofballtech mentioned, this is the number of errors & warnings associated with a given file. You can turn this off by setting problems.decorations.enabled to false in your VSCode settings.json.
You can find more information here: https://code.visualstudio.com/updates/v1_20#_error-indicators-in-the-explorer

Related

How do i prevent vscode from breaking my pasted code?

Im not using any plugins for breaking my code, i think it's an integrated function. This problem is now since a few weeks and it's driving me crazy pasting code and then putting every line back.
Here is a screenshot of my code (i just copied this line):
https://imgur.com/YOdfM2u
Here is a screenshot of my code (i pasted it):
https://imgur.com/1AfzNIH
Why is my vscode breaking the lines everytime?
Thanks in advance for your help, i really apreciate it
This is the default formatter wrapping text (or trying to) at the default of 80 columns.
If you want to override this, you can do so by adding this line to your settings.json file:
"html.format.wrapLineLength": 0
If you prefer to change your settings from the GUI instead of the json file, open the command palette and open the settings from there. Once in it, look for "HTML format wrap line length" in the search box and change the value to 0.
You find a shortcut to the settings here too:

How do I Change VSCode To Indent 4 Spaces Instead Of Default 2?

I have applied the below settings in VS Code to get 4 spaces indentation.
But always when I open a new file, it switches back to 2 in the right-bottom corner.
If I click in the right-bottom corner and change the setting back to 4,
VSCode will still change back to 2 and still apply it with the 2-space auto-indent.
Alt+Shift+F
What am I missing?
Bit of an late answer. But just got the same issue solved...
Multiple things are able to control this. It also has taken me quite a bit of experimentation to get it corrected. For me point 3 below was the final trick to make it work. Before that, I noticed the editor loading with 4, but jumping back to 2 spaces. Now it stays at 4.
Some things to check:
1: VS Code configuration (Settings & Workspace, you can set these for system wide configuration or just for the current Workspace):
Check whether you have set:
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.detectIndentation": false
And language specific settings (optional):
"[javascript]": {
"editor.tabSize": 4
},
"[typescript]": {
"editor.tabSize": 4
}
2: Are there any Extensions that could influence the indentation -> people have reported JS-CSS-HTML to also configure the setting.
3: Is there a .editorconfig file in your workspace? If so, check the settings over there. Angular creates one for example and configures the indent_size:
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
Most answers focussed point 1 which, but for me the last step was important to make VS Code work properly.
This Stack Overflow handles all of the above in different answers:
Visual Studio Code: format is not using indent settings
I fixed it in the VisualStudio settings (1.31)
Go to: settings > workspace settings > Text editor
uncheck 'Detect Indentation' to stick to your default setting.
In many cases, it is Prettier that causes this. In fact, it just ignores all settings listed in #Oskar's answer.
So it needs to be overridden explicitly:
"prettier.tabWidth": 4,
"prettier.useTabs": true
And then just go to your file and hit Ctrlk,Ctrld, and the correct indentation should be applied.
See also Prettier is not indenting as specified.
Slightly different from previous answers. I had one file with the wrong indentation for its type and I wanted to correct only that file.
(If you must know: this Python script started out as text file with some queries in it. I got it from psql's -E \d echo look at the postgres schemas).
Anyway, this file was now a Python .py file, with a 2 spaces indentation. Not something that should be fixed by modifying general vscode settings.
What I did:
click on the bottom status bar spot that says 2 Spaces
choose Convert Indentation to Tabs on the dialog popup. Now it says Tab size 2
click on the status bar again where it says Tab size 2
choose Convert Indentation to Spaces. Now the dialog changes to propose indent size: 2 is selected. Pick 4 instead or any size you want.
Done
Basically there are different ways through this dialog, but if you get into tab mode and then switch back to space-based indentation, it will allow you to pick the number of spaces you want to use.
Be careful; this extension EditorConfig for VS Code interferes with vscode tab and indentation settings. Its installed by default but it is a nightmare. Disable it will solve all your problems.
Another problem I discovered with Python is that VS Code uses autopep8. No matter which setting I tweaked, VS Code seemed to ignore the 2 spaces setting. If you want 2 spaces instead of 4 - the fix is to add this to your settings.json.
"python.formatting.autopep8Args": [
"--indent-size=2",
"--ignore E121"
]
Btw you can see your autopep8 arguments by opening the command palette (⌘-shift-p on mac) and entering >Python: Show Language Server Output then switching to view the "Python" log.
This seems to be a common issue. See: VS Code Python autopep8 does not honor 2 spaces hanging indentation

How can I change the file sorting of VS Code?

In my project I have files labeled as such day1.txt, day2.txt, day3.txt, etc.
Now in my normal file system they are listed in the correct order:
day1.txt
day2.txt
....
day10.txt
day11.txt
In VS Code they are listed like so:
day1.txt
day10.txt
day11.txt
day2.txt
day3.txt
Is there a setting somewhere to change this? It is driving me mad.
I've given the settings a search and I didn't see any obvious parameter to change that would affect this.
Yes there is a way.
In your Settings (File → Preferences → Settings) search for: explorer.sortOrder
A small pen will appear on the left side of the setting. Select the way you want to sort the files. There are five options available:
Default
Mixed
Files first
Type
Modified
Unfortunately, there's no option that will allow you to sort all of the open editors alphabetically.
No, unfortunately there's no such option as of yet, but there's already a feature request.
Maddening having to constantly search for the file in the OPEN EDITORS section. Such a nice program otherwise. What a shame.

How to filter files shown in Visual Studio Code?

How would you filter the files shown in the folder view in Visual Studio Code?
Reference: Filter files shown in folder
Hiding files and folders
The files.exclude setting lets you define patterns to hide files and folders from several places in VS Code like the explorer and search. Once defined, files and folders matching any of the patterns will be hidden.
{
"files.exclude": {
"**/*.js": true
}
}
Hide derived resources
If you use a language that compiles to another file at the same location of the source file, like TypeScript does to JavaScript, you can easily set an expression to hide those derived files:
"**/*.js": { "when": "$(basename).ts"}
Such a pattern will match on any JavaScript file (**/*.js), but only if a sibling file with the same name and extension, *.ts in this example, is present. The same technique can be used for other transpiled languages, like Coffee Script or Less/Sass, too.
Source: VS Code v0.5.0 (July 2015)
In version after VScode 1.70 (July 2022) all you need to do is press Ctrl+F or F3 to search.
Please refer following post
Searching in Explorer panel after VSCode 1.70
Only applicable for v1.69 and below.
Step #1
Click on Explorer window. This is critical as without focus on Explorer it will not work.
Step #2
Start Typing name you want to filter. It's weird that there is no textbox to take input but... take a leap of faith and type. You will see your typed text in top-right corner in brown background. Now hover on that text.
Step #3
Click on 3 stacked lines to filter..
They look like hamburger menu but they are not. They are saying if it's filtered or not. They are toggled between filtered and just highlight. So, make sure they are like inverted pyramid.
That's it. It should be filtered now.
If you only want to change the setting for this project, then do the following:
File > Save Workspace As > ... enter your {project name}
Then open file: {project name}.code-workspace
And update section settings.
Sample:
{
"folders": [
{
"path": "."
}
],
"settings": {
"files.exclude": {
"**/*.log": true
}
}
}
VScode 1.70 (July 2022) should improve on this "tree filter" feature.
(Available today in Code insiders)
See issue 70646 and PR 152481:
Support find widget in lists/trees
This PR replaces the existing list/tree type filter:
with an bona fide find widget:
While a seemingly simple change, this has some (desired) consequences when searching/filtering in trees. Namely:
We will restore simple keyboard navigation by default.
That is: pressing the letter A will focus the next element which starts with A.
Initiating a search operation requires pressing Ctrl-F or F3, like the editor.
While searching, focus is in the find input box as opposed to the list itself.
Pressing DownArrow will focus the first list element which was found.
We'll preserve all custom behavior of context keys, eg. used by the VIM extension).
In VIM, the pre-existing / command will trigger simple keyboard navigation, as opposed to opening the find widget.
The VIM extension has the option to change this behavior themselves.
And:
In general:
Keyboard navigation is now called type navigation
Filter on type is now called find mode, aligned with a new find concept
Settings
workbench.list.keyboardNavigation has been renamed to workbench.list.defaultFindMode
workbench.list.automaticKeyboardNavigation has been deleted
Commands
list.toggleKeyboardNavigation has been renamed to list.triggerTypeNavigation
list.find has been added
list.closeFind has been added
list.toggleFilterOnType has been renamed to list.toggleFindMode
Context Keys
Mainly used by the vim extension:
listSupportsKeyboardNavigation has been renamed to listSupportsTypeNavigation
listAutomaticKeyboardNavigation has been renamed to listTypeNavigationMode
"With the focus on the File Explorer start to type part of the file name you want to match.You will see a filter box in the top-right of the File Explorer showing what you have typed so far and matching file names will be highlighted."
"Hovering over the filter box and selecting Enable Filter on Type will show only matching files/folders."
documentation: https://code.visualstudio.com/docs/getstarted/userinterface#_filtering-the-document-tree

Beyond Compare Ignore Unimportant Differences in all files

I am using Beyond Compare 3.3.4.
I want to compare a large number of files and ignore unimportant differences.
In Session -> Session Settings -> Comparison tab, the "Requires opening files" section has a "Compare contents - Rules-based comparison". This does what I want when I open each file individually. The "quick test" section doesn't have this option. How do I apply rules-based comparisons to my "quick test"?
EDIT:
I am having the same problem as the original poster here. The answer given was "You can change this by going to the Session menu and changing your Comparison Criteria to use Rules-based content". Problem is, the "Rules-based comparison" is under the "Requires opening files" section, so this doesn't work. How do I fix this?
This answer describes the behavior of 3.3.4 (and 3.3.8) for Windows 32-bit, which seems to automatically report folder results as if I'd opened each file, as long as I have my session settings correct.
To perform a comparison that ignores unimportant differences, it is necessary to compare the file contents. BC3 can't know if line endings are the only difference (for example) unless it scans the contents for line endings. Therefore, you must set the "Compare contents" checkbox under the "Requires opening files" section. By doing so, the folder comparison automatically scans all file contents, I don't have to open each one individually.
A "quick test", by definition, is based solely on directory information like timestamp and size. It is quick because it does not open nor read the files; so if quickness is what you desire in a comparison, it cannot be rules-based. The concepts are incompatible.
You can see whether a "quick" or "contents" comparison has been run for any pair of files in a folder-compare window by looking at the middle column. If it is blank, only a quick test has been run; if there is an icon, a contents test has also been run.
That icon will be a black ≈ ("almost equal") symbol, two wavy lines, when a "Rules-based comparison" has detected only unimportant differences. The files themselves will be black and treated as matching if you have "View > Ignore Unimportant Differences" active, otherwise they'll be red or gray and treated as mismatching.
For the meaning of each possible icon, here is the relevant section from the Beyond Compare 3 help file:
Please find below screenshot. Hope this will help.