Textmate 2: How do I set the tab size for .rb files? - textmate2

I have a .tm_properties file in my home folder with the following contents:
softWrap = true
tabSize = 4
softTabs = true
However, if I open an .rb file and hit tab, it will only indent 2 spaces on the new line. How can I make it 4?

In addition to global settings in the home folders ~/.tm_properties, there are also ./.tm_properties for file types (below) or by project ([project folder]/.tm_properties)
Find more about the settings (credit dvessel).
In short:
[ *.rb ]
tabSize = 2

2 seconds after I post the question I discover that this is managed in the View menu.

Related

Cmd + S of TeX file in Sublime Text turns off spell check [MacOS] [duplicate]

This question already has an answer here:
Sublime Text - spell check but only certain file extensions
(1 answer)
Closed 4 days ago.
Problem
I have been experiencing this weird effect where every time I press Cmd+s to save a .tex file, the spell check gets disabled.
I tried ...
This bug is not there in other file types (tested on .txt, .py, .bib, .nml)
Builds
I use Sublime Text build 4143 on MacOS Monterey 12.6.3. and I edit .tex files to build documents using the Sublime package called LaTeXing 1.4.0.
Any hints are appreciated.
The procedure in the link pointed out in the comments by #Parthis worked for me.
In short:
Open a .tex file (or whichever file you want to keep the spell check on).
Go to Preferences > Settings - Syntax Specific. This will open a settings file specific to .tex. Mine was blank with only { }.
Add "spell_check": true between the { }
Now my spellcheck is not affected by Cmd+s anymore!

Sublime keeps using 4-space tab for some files instead of 2-space tab even if I've done all the settings, why and how do I fix?

I'm editing files using Sublime 3.2.2 on my iMac.
I have already set tab-size to 2:
It works for some files but doesn't for some files - remaining 4-sized tabs. I can't even find a clue about which is right and which is not.
Are there any other places I need to check except the settings?
There are two things to consider here. First, this setting (shown here with the default value):
// Set to false to disable detection of tabs vs. spaces on load
"detect_indentation": true,
When this setting is turned on, when a file opens it's examined to try and detect how it;s indented. This will override the tab_size in that particular file with whatever the detected tab size is, and can also override translate_taba_to_spaces as well if the file appears to be indented a particular way.
The setting defaults this way so that you can use your settings to determine how you want to create new files while still allowing you to work with existing files in a sane way; setting it to false turns off this detection.
The second thing to note is that preferences can be set on a per-file-type manner, which also overrides the settings in your user preferences for files of that type.
As an example, YAML files have these settings applied (this is from YAML/YAML.sublime-settings):
{
// YAML mandates that tabs aren't used for indentation
"translate_tabs_to_spaces": true,
// In practice, editing YAML files with anything other than two space
// indentation is tedious, due to the "- " list prefix
"tab_size": 2,
}
So, in a YAML file, regardless of your settings, the tab size defaults to 2 and using spaces over tabs is enforced.
As such, the takeaway here is that if changing the detection setting above doesn't work, check to see if the setting only seems to be "not working" in a particular type of file, and if so you can use Preferences > Settings - Syntax Specific while you have a file of that type open to enforce your settings there.

How to configure Sublime Text 3 editor settings for specific file extensions?

I want to change some editor settings that's only applicable to certain file extensions.
As a test I created 2 files with these contents (in essence overriding what I have as default):
> cat Preferences.sublime-settings
{
"tab_size": 2,
"translate_tabs_to_spaces": true
}
> cat Powershell.sublime-settings
{
"tab_size": 12,
"translate_tabs_to_spaces": true
}
> cat Ps1.sublime-settings
{
"tab_size": 12,
"translate_tabs_to_spaces": true
}
I closed and reopened Sublime Text and pressing the tab key still produces 2 spaces for tabs instead of 12.
Any ideas on how to make it work? Thank you.
This answer assumes you have already installed and been trying to configure the PowerShell package from Package Control.
The reason your settings are not working is because the settings' file names that you tried are wrong. The PowerShell package uses the file name PowershellSyntax.sublime-settings for its settings, that is what you need to use.
Most packages use their package name as the file name for their .sublime-settings file but clearly not all do. In this case there is a much older PowerShell package called stposh which already made use of the file name PowerShell.sublime-settings so, in all probability, the developer of the newer PowerShell package was forced to choose a different file name to avoid a conflict. Clearly the choice of PowershellSyntax.sublime-settings made setting up the package less intuitive, in my opinion the settings file name should be mentioned in the package's README.
// Save as 'PowershellSyntax.sublime-settings'
// in your Sublime Text config 'User' folder.
{
// 8 or even just 2 is probably better to test with
// but stick with the massive 12 if you want to. :)
"tab_size": 12,
"translate_tabs_to_spaces": true
}
In future if a .sublime-settings file does not work, look on the package's homepage which is always linked from Package Control. A browse through the source file names will usually quickly reveal the correct settings file name to use. If the package is already installed, you could also open its .sublime-package file, which is a zip archive, these are stored in the Installed Packages folder.
Some Extra Hints:
The PowerShell Package should automatically recognise the following file extensions .ps1, .psm1, .psd1 and use its syntax when they are opened. To force another file extension to automatically use that syntax, e.g. .ps, click on the currently active syntax name on the far right of the status bar, a context menu will be shown, hover the mouse pointer over Open all with current extension as..., and then select PowerShell from the list.
To manually instruct Sublime Text to convert tabs to spaces, or vise versa, click on where it says either Spaces: n or Tab Size: n on the status bar, doing so will open a context menu. You can then switch between spaces and tab indentation by selecting or unselecting Indent Using Spaces. Open the same context menu again and select whichever conversion is then required from the bottom 2 menu items. This last stage can also be performed by typing indentation into the Command Palette and choosing from the self-explanatory options.

master config file to set tab=4 spaces for every editor at once

I've had to edit configuration files for all of my various editors (emacs, vim, nano, etc.) to have a tab spacing equal to 4 spaces instead of the seemingly default 8. Is there a more elegant way? Some master file I can point them all to in order to use the same tabs/spaces settings for all of them?
Try to use http://editorconfig.org (you need to place .editorconfig in each project)

How can I show dotfiles in Textmate 2?

I recently upgraded to Textmate 2 and now my dotfiles are not showing up in the file browser. Obviously, this is important when working with stuff like .htaccess files.
Is there a way to enable this feature?
Quick solution
Move the focus to the file browser (⌥⌘⇥) and show invisibles (⌥⌘i)(key names: option/alt+command/windows+i/eye). All invisible files will appear in the file browser. Press ⌥⌘i again to hide them.
Permanent solution
If you want to always show some dotfiles (for instance .htaccess), you can either add them in Preferences > Projects > Include files matching…
or add the list of files you want to show to the include array in one of:
~/Library/Application Support/TextMate/Global.tmProperties (same as using Preferences)
~/.tm_properties (global)
.tm_properties (inside a specific directory/project)
You can add all dotfiles (.*) but I don't recommend it since it can be a lot of clutter.
That said, you can also exclude files with the exclude array.
You can modify the behavior of the file browser via the config file ~/.tm_properties
To list all dotfiles and directories, you can set:
include = "{$include,.*}"
If you want to exclude some of those, for example the .git directory, modify the exclude variable:
exclude = "{$exclude,.git}"
There are many more options, check the Textmate site as an entry point for whats possible: http://blog.macromates.com/2011/git-style-configuration/
You can do this in the preferences of Textmate 2.
Navigate to: Textmate -> Preferences -> Projects. You should see two fields, one for including files, and one for excluding. I replaced the value of "Include files matching" with {*,.*} so it includes all normal and hidden files. I then just add the hidden files I want to exclude to the "Exclude files matching" field, such as .git and .DS_Store.

Resources