I'm currently using VSCode and I have this problem. I want to set the space size equals to 1 and tab size equals to 2 as default for every project. But it still set back as spaces: 4 for every project.
And as I set the spaces = 2, and run Beautify file. Everything looks good with space = 2. Then I hit save it format my file to indent size 4. How do I set it as default equal to 2 guys?
even I change in User settings
By default VSCode try to detect indent option for a file. So set editor.detectIndentation to false
// When opening a file, `editor.tabSize` and `editor.insertSpaces` will be detected based on the file contents.
"editor.detectIndentation": false,
EditorConfig is a handy standard for establishing project wide formatting options: http://editorconfig.org.
There's a VSCode extension supporting it: https://github.com/editorconfig/editorconfig-vscode
This doesn't directly answer your question, but it works well. And if you switch editors, you still can keep your formatting standard by getting each editor's plug-in for EditorConfig.
Related
I'm experiencing an issue in VS Code when using the auto formatter to fix indentation in HTML files. On hitting the shortcut Shift + Alt + F, the document is indented with 4 spaces instead of 2.
Before using auto format:
HTML written with emmet, before using auto format
After using auto format:
The same HTML, after hitting Shift + Alt + F
Here are my user settings:
"editor.tabSize": 2,
"editor.insertSpaces": false,
"editor.detectIndentation": false,
Do these user settings have any influence on the auto-formatter for HTML? All other file types appear to indent correctly according to these settings, or with their associated linters.
I have no workspace settings set for the editor, just the user settings and no extensions installed that might change the way this behaves. I have also tried installing the Beautify extension by HookyQR and then setting various config files, these don't seem to influence this formatting behaviour. I have also tried HTMLHint, again no luck.
I am a bit stuck, and bored of manually formatting the indentation of my HTML files!
I've created a bunch of snippets in Sublime Text 2, but I cant remember them all off the top of my head. I've seen in a number of tutorials that as people start typing their snippets tab-triggers it will start to provide a list of the matching snippets. I don't see this.
Is there a setting somewhere for this? Or do I need to create a special file (completions file?). For most snippets I have the <scope> commented out as I may use in a PHP or HTML file for example depending what I am working on.
Most of my snippets tab triggers start the same elq- prefix, so it would be very helpful if it were to start showing me the options as I type.
The setting auto_complete_selector controls when Sublime automatically offers the popup for possible completions. The default value for this setting is:
// Controls what scopes auto complete will be triggered in
"auto_complete_selector": "source - comment",
This means that it will automatically pop up for any file that's considered a source code file, except within a comment.
The scopes for the file types that you mention in your question are text scopes and not source scopes, which stops the popup from appearing.
One way around that would be to manually invoke the auto complete panel by using the appropriate key binding, which by default is Alt+/ on Linux or Ctrl+Space on Windows/OSX. When you do that, the popup for possible completions at this point is manually displayed.
To allow this to work more automatically, you would need to modify the setting for auto_complete_selector to be more appropriate for your situation.
To do that you could select Preferences > Settings - User from the menu and add or modify the auto_complete_selector setting as follows:
"auto_complete_selector": "source - comment, text.html",
This says that the selector should always be displayed in source files except inside comments (like the default) and also within HTML files.
You could also use text instead of text.html if you want it to work in all text files of all types, although this would possibly get quite annoying while working with plain text files. Substitute an appropriate scope or set of scopes here as appropriate to dial in the places you want this to be automatically offered.
By default when I open file it looks as follows:
And I want always unfold when I open a file
Is there any keybinding exist that can unfold everything automatically not require any command from keyboar ? Thank you !
If you last saved a file while it was folded, Sublime will remember that. Select Edit -> Code Folding -> Unfold All, make a small change like adding then deleting a space, then resave the file. It will open unfolded next time.
Also, as a point of style, please use 4 spaces for indentation. Using 1 space, it's almost impossible to differentiate the various indentation levels. 2 spaces is almost as bad. With a Python file open, select Preferences -> Settings-More -> Syntax-Specific - User and add the following:
{
"tab_size": 4,
"translate_tabs_to_spaces": true
}
I have the following in my user/Preferences.sublime-settings
{
"tab_size": 2,
}
And most of the time it works. But once in a while I open a ruby file, and it jumped back to 4 spaces. I'm wondering if there is some bug or slight difference in opening a file that could change this?
Having trouble tracking this down. Thanks for the help.
You'll want to add:
"detect_indentation": false
This is on by default and ST is trying to be smart detecting the indentation of your current file, overloading the user or syntax specific default.
Here are various Sublime Text 2 tab settings explained:
http://opensourcehacker.com/2012/05/11/sublime-text-2-tips-for-python-and-web-developers/#Configure_sane_tab_and_whitespace_policy_and_other_settings
Note that the tab setting may be per file type
There is also autodetect from file enabled by default and your source code file may contain bad tabbing
I use Sublime Text and want JavaScript files to use three spaces for indentaiton.
I set this in Packages/User/Preferences.sublime-settings:
{
"tab_size": 3,
"translate_tabs_to_spaces": true
}
but it has no affect and I need to manually change it for each new file.
When you have a JavaScript file open do the following:
Per-syntax Settings
Settings may be specified on a per-syntax basis. You can edit the
settings for the current syntax using the Preferences/Settings -
More/Syntax Specific - User menu.
This will allow you to set custom preferences for the current syntax. More info on indentation here: http://www.sublimetext.com/docs/2/indentation.html