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"]
}]
}
Related
I just installed sass-lint in my VS Code editor and I keep on getting this error for each and every property(line) I've set in my *.scss files:
[sass-lint] Mixed tabs and spaces
Indentation type in VS Code is set to tabs(4), it is set to indent using Tabs.
How can I disable mixing of tabs and spaces for sass-lint?
To close this one off, I later on found out that it is a best practice to use a EditorConfig file to pre-set all of your workflow settings.
This is a plugin-type settings file, which pre-configures desired settings to fit your workflow.
In my case, I use EditorConfig for VScode. After you add it to your editor of choice, simply create a .editorconfig file in your base(root) directory and fill it with the desired settings.
e.g. , my base setup looks like this:
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
The real reason is: SASS Lint isn't recognizing your indentation settings and it's using it default indentation (2 spaces). It's looking for 2 spaces and found tabs instead.
You can confirm it by removing all indentation and reading the hint.
As pointed on Pull#725, the correct syntax is:
indentation:
- 1
-
size: 'tab'
I found that sass-lint in Sublime Text 3 wasn't loading my config file.
I got it working after reading this GitHub issue:
In SublimeLinter preferences (Preferences -> Package Settings -> SublimeLinter -> Settings):
"linters": {
"sass": {
"working_dir": "${/home/myusername}"
}
},
Add the file .sasslintrc to your Home folder:
{
"rules": {
"indentation": [
1,
{
"size": "tab"
}
]
}
}
Sublime text opens, wants to reload old files because they have changed, I reload a few and then it crashes.
Is there a way to start Sublime Text afresh, letting it forget the last files that it had open?
In Sublime Text 3 set hot_exit to false in "Preferences -> Settings-User"
"hot_exit": false
remember_open_files doesn't exist in Sublime Text 3 settings anymore.
Go to Sublime Text
Choose
Preferences >> Settings-User
Add the code below to the current settings. (Remember to add a comma at the end of the first line if it doesn’t) and save it.
{
"remember_open_files": false,
"hot_exit": false,
}
So I have a folder open in Sublime Text 3.
This folder contains a structure like this:
src
build // I would like to hide this folder
.sass-cache // and this folder
node_modules // and this folder
task
test
In the folders pane on the left (the sidebar), I get the above folders. I would like to hide some of them from view and only see the remaining folders.
Is there a way to achieve folder hiding using a list or another file which is loaded on launch?
I was thinking something like a .gitignore file or such, which just lists folders or patterns to hide things from view.
You need to set "folder_exclude_patterns" and/or "file_exclude_patterns" in your preferences. The defaults are as follows:
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS"],
"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"]
Select Preferences -> Settings—User, then add the following line:
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", "node_modules", ".sass-cache", "build"]
If you are working in a project, select Project -> Edit Project, and add the line above to the "settings" dict. In both cases, make sure the file is valid JSON.
For reference, here's a minimum working example for a project file with excluded files and folders:
{
"folders":
[
{
"path": ".",
"file_exclude_patterns": ["*.sublime-project", "*.sublime-workspace"],
"folder_exclude_patterns": [".idea", "__pycache__"]
}
]
}
Is there a way to filter out files by extension in Sublime Text?
add file_exclude_patterns to your user preferences file. this is how mine looks like:
"file_exclude_patterns":
[
"*.tmTheme.cache",
"*.tmPreferences.cache",
"*.tmLanguage.cache",
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
"*.obj",
"*.o",
"*.a",
"*.lib",
"*.so",
"*.dylib",
"*.ncb",
"*.sdf",
"*.suo",
"*.pdb",
"*.idb",
".DS_Store",
"*.class",
"*.psd",
"*.db"
],
In addition to "file_exclude_patterns", you can also use "folder_exclude_patterns".
Referencing this comment from zbynour: with an appropriate product directory structure, combining both directives makes it easy to exclude folders with compiled TypeScript output, sass-cache, etc without excluding e.g. all .js files.
Also, you can specify these exclusions on a per-project basis using your project's .sublime-project file. Here's one of my .sublime-project files, which lives in the project's root directory.
{
"folders":
[
{
"path": ".",
"folder_exclude_patterns": [".sass-cache"],
"file_exclude_patterns": ["*.pdf", "*.psd"]
}
]
}
Of course, you can also use these directives together in your User/Preferences.sublime-settings file. Doing so will of course affect all of your sublime sessions, for all open folders and/or projects, which for me, having forgotten about the setting several months later, caused some bewildering, head-scratching confusion.
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.