Reputation:
In some of my PHP files Sublime shows vertical lines (tab stops?) spaced 2 characters apart, and other files default to having these vertical lines at 3 characters apart (my preferred tab length).
Vertical lines can be seen below (these lines being 3 characters apart):
[Note I can't post a screenshot because I don't have enough points!]
My user preferences file is as follows:
{
"draw_white_space": "none",
"ignored_packages":
[
"Vintage"
],
"tab_size": 3,
"translate_tabs_to_spaces": true,
"detect_indentation": false,
"smart_indent": false,
"use_tab_stops": false,
"trim_trailing_white_space_on_save": true,
"fallback_encoding": "UTF-8",
"rulers": [80, 120]
}
I have tried different permutations of detect_indentation, smart_indent and use_tab_stops, i.e. totally omitting and true / false etc. This made no difference.
I'm really surprised that: a) There is inconsistency between different PHP files, i.e. some default to having vertical lines of 2 characters apart and others 3 characters apart. b) The user settings don't have the effect I expect.
Any Sublime Text 2 experts know how to get these vertical lines to default to my tab width setting?
Many thanks.
Upvotes: 5
Views: 7102
Reputation: 506
The both methods are valids, but I think that you should know about the file Preferences.sublime-settings
, this are the default preferences for all enviroment.
You can acess Preferences.sublime-settings
going to:
Prefenrences > Setting - Default
on the main menu. Or accessing the path:
/home/<user_name>/.config/sublime-text-3/Packages/Default/Preferences.sublime-settings
for Linux Users, but at others operatings systems have arquitecture similar, except by the particularities of access to directories. Like Windowns C:\\Programs Files\Sublime Text 3\[...]
The file Preferences.sublime-settings already have many paramters pre-difined and you just need to assign values to your liking. The range of possible values, in general, are true, false or numeric.
For you case you should change the values of "tab_size"
, by default it receive 4 spaces as value - It's perfect for Python programmers), simply change to the desired value.
// Set to true to turn spell checking on by default
"spell_check": false,
// The number of spaces a tab is considered equal to
"tab_size": 4,
// Set to true to insert spaces when tab is pressed
"translate_tabs_to_spaces": true,
// If translate_tabs_to_spaces is true, use_tab_stops will make tab and
// backspace insert/delete up to the next tabstop
"use_tab_stops": true,
The settings that I always like of change the value are:
"translate_tabs_to_spaces": true, //prevents that to switch from editor the indentation be changed.
"highlight_line": true, //highlights the line where the course is.
"auto_complete_commit_on_tab": true, //allows complement of code structure with tab key.
Upvotes: 1
Reputation: 567
Because this refers to a syntax specifically in PHP, the settings have to be saved directly in a "Syntax Specific" settings file. Open the file Packages/User/PHP.sublime-settings
in the packages folder and write the following:
{
"tab_size": 3,
"translate_tabs_to_spaces": true,
"detect_indentation": false
}
But if you want it to be like this for all your code (i.e. not just PHP), place it in the Packages/User/Preferences.sublime-settings
file instead.
Upvotes: 10