error msg setting editor preferences, format on save, format on paste for Prettier - unable to write into user settings. How do I correct this, pls? - format

Installed Prettier. Want to set preferences to format on paste and save but getting error message - unable to write into user settings. Please open the user settings to correct errors/warnings in it and try again.
To format prettier I went into the extension, typed in format and tried to select Format on paste and format on save. That's when the error message appeared. When I check settings, I see this:
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
What can I do?

Follow the steps it might help you:
Open the user settings file by going to Preferences > Settings in the VS Code editor, or by pressing the keyboard shortcut Ctrl+ (on Windows) or Cmd+ (on Mac).
In the Settings editor, find the section for "editor.formatOnPaste" and "editor.formatOnSave". Make sure that these settings are set to true, like this:
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
Check the rest of the file for any syntax errors or warnings. In your case, it looks like there is an extra comma at the end of the "[jsonc]" and "[html]" sections, which is causing the error. Remove the extra comma, and make sure that the file is properly formatted and indented.
Save the changes to the file, and try setting the formatting options again.
This should work now that the syntax errors have been fixed.

Related

vscode open unknown window when i open setting.json file

I'm very confuse about left window in my screen shot when i try to open setting.json file.
do someone know what is this window are and how to hidden them.
It's the arguments for the flake8 linter, look at like 23 and line 24.
You can try something like
"python.linting.flake8Args": [
"--max-line-length=120"
]
The Answer is this left window is call "default setting" from vscode
can the way to close them is add this setting into setting.json file
or remove it from setting.json file (default is should be false already)
"workbench.settings.useSplitJSON": false,
but for some reason it set to True in my setting.

Sublime Text - spell check does not work for .txt files (while working for other files)

Sublime Text - spell check does not work for .txt files (while working for other files).
Why? How to fix? Any ideas?
Also: in a new file (not yet saved) the spell check works. However, after the file is saved as .txt, the spell check does not work. Unexpected. Why? How to fix?
The Preferences.sublime-settings has:
"spell_check": true,
and nothing special for .txt files.
Sublime Text, Build 4126.
UPD. In safe mode:
Here we see that in helloe.bash the helloe is not spell-checked. Why?
The Bash.sublime-settings has:
// These settings override both User and Default settings for the Bash syntax
{
}
UPD2. After adding "spell_check": true in Bash.sublime-settings the helloe is still not spell-checked. Any ideas why?
Multiple things to check:
Check how .txt files are syntax-highlighted. In my case .txt files are syntax-highlighted as .bash files (it is needed by some reason).
If .txt files are syntax-highlighted as .bash files, then helloe is a variable name, which is not spell checked by default. As user #OdatNurd said:
spell_check controls weather or not spell checking is turned on or not, but spelling_selector determines what text is actually spell checked. Specifically, in source code files it's basically strings and comments. In your example the text is a variable name. If you want to alter that, you need to alter the spelling_selector too.

How to Prevent Trimming Trailing Whitepace in VSCode?

I'm using VS Code Version: 1.45.1 on Macos using the built-in Text Editor, editing a .yml file.
As soon as I start typing in the file, the editor immediately trims all trailing whitespace from every line in the file. How do I prevent that from happening? Even better would be if there was a single setting to prevent it from making any automatic edits to anywhere in the file including adding a final newline, etc.
I tried adding the following to my settings.json and restarting VS Code but it didn't seem to have any effect:
"[yml]": {
"editor.formatOnSave": false,
"editor.trimAutoWhitespace": false,
"files.trimTrailingWhitespace": false,
"files.trimFinalNewlines": false
},
I also tried with other file extensions including *.js and I saw the same behavior.
The reason was due to the EditorConfig extension -- reconfiguring that solved it.

Hide files with certain extension in Sublime Text Editor?

is it possible to hide all the files with certain extension from the sidebar (lateral nav bar) in Sublime Text Editor 3?
Are you talking about the sidebar? For example, if you select File → Open and select a folder, then the folder and its contents are displayed along the left side, allowing you to navigate amongst its contents and sub-directories. If that is the case, then the answer is yes, files can be excluded.
Select Preferences → Settings – Default to open a tab called Preferences.sublime-settings – Default. This file is read-only, so you'll also need to open Preferences → Settings – User. The first time you open your user preferences it will be blank. It (and all Sublime config files) are in the JSON format, so you'll need opening and closing curly braces at the beginning and end of the file, respectively:
{
}
Activate the default preferences tab and search for file_exclude_patterns (which is on line 377 in ST3 build 3083) and also folder_exclude_patterns if desired. Copy its contents to your user preferences file, like so:
{
"file_exclude_patterns": ["*.pyc", "*.pyo", "*.exe", "*.dll", "*.obj","*.o", "*.a", "*.lib", "*.so", "*.dylib", "*.ncb", "*.sdf", "*.suo", "*.pdb", "*.idb", ".DS_Store", "*.class", "*.psd", "*.db", "*.sublime-workspace"]
}
and feel free to add your own customizations. Please note that there is no comma (,) after the closing square bracket, as in this example this is the only customized preference. If you have multiple ones (changing fonts, window options, themes, or whatever) you'll need a comma after each item except the last one (trailing commas are illegal JSON):
{
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"word_wrap": true,
"wrap_width": 0
}
You can also set them up per project and ignore folders, in your .sublime-project file, e.g.:
{
"folders": [{
"path": ".",
"folder_exclude_patterns": [".svn", "._d", ".metadata", ".settings"],
"file_exclude_patterns": ["*.pyc", "*.pyo", ".project"]
}]
}

Sublime Text 2 - Default Document Type

Is there a way to set a default document type when saving a NEW FILE?
I created several new files and I want to have a default value of .txt when saving a NEW FILE.
Create a new plugin Tools > Developer > New Plugin...
Paste this in:
import sublime, sublime_plugin
class EverythingIsPowerShell(sublime_plugin.EventListener):
def on_new(self, view):
view.set_syntax_file('Packages/PowerShell/Support/PowershellSyntax.tmLanguage')
Save and call it NewTabSyntax.py. New tabs will now default to Powershell.
You can change the syntax to whatever you prefer. To find out the "path" of a particular syntax, simply open a file of that syntax, open the console (View > Show Console) and type:
view.settings().get('syntax')
This plugin does it:
https://github.com/spadgos/sublime-DefaultFileType
seems pretty great.
Edit:
Ok, two things, there currently seems to be a small bug so the text file syntax is not being correctly picked up due to the whitespace in the filename. In addition you need to set the "use_current_file_syntax" to false, (otherwise the new file will default to whatever filetype you have open already when you hit Ctrl-N)... So the fix/workaround is this:
Put the following code in: Packages/User/default_file_type.sublime-settings
{ "default_new_file_syntax": "Packages/Text/Plain_text.tmLanguage",
"use_current_file_syntax": false }
NOTE THE UNDERSCORE.
Next, find the "Plain text.tmLanguage" file and copy and rename it (in the same folder) as "Plain_text.tmLanguage". [be sure to copy/duplicate it, do not just rename it, as it may have dependancies]
Restart, just to be sure, and this should do the trick.
Also note this plugin only works for new files created with Ctrl-N.
Working after these steps:
1.Uninstalled
2.Installed using Package Control
3.Test using default install (type Jave) <-- worked
4.Copy and Renamed file Sublime Text 2\Packages\Text\Plain text.tmLanguage > Sublime Text 2\Packages\Text\Plain_text.tmLanguage
5.Changed file Sublime Text 2\Packages\Default File Type\default_file_type.sublime-settings >
`{ "default_new_file_syntax": "Packages/Text/Plain_text.tmLanguage", "use_current_file_syntax": true }`
-- All working.
I did not need to copy any files into the 'Packages/User' folder
#fraxel _ Thanks for all the help and quick response.

Resources