Sublime text 3 and overriding settings per project doesn't work - sublimetext3

I've setup to my user settings on sublime text 3, the following option: trim_trailing_white_space_on_save: true
But it seems our collagues have a different opinion regarding of it and if it is useful. So I have to override this setting per project (I wanted to other projects, I just want to be skipped on a specific one). I've tried by creating a file .sublime-workplace and/or .sublime-project on the root of the project folder and I added the following:
{
"settings":
{
"trim_trailing_white_space_on_save": false
}
}
But when I save a file with whitespaces, it still keeps trimming them. What am I doing wrong? Is there specific settings which I can bypass per-project? If yes, is there another way of doing that (maybe a sublime plugin or something).

From the description in your question, the problem may be that you created the project file but didn't actually open it. Sublime only treats paths with a project file in them specially if you open the project, e.g. via Project > Open Project or from the command line via subl --project path/to/project.sublime-project.
Additionally, without a list of paths to include in the project, the project defaults itself to being empty, which is probably not what you want.
From your existing window that you're already working with, select Project > Save Project As... to save a project and workspace that captures the current state of everything; folders visible in the side bar as well as any files that may already be open. Once that's done you can use Project > Edit Project to edit the project file and add the setting as you did above.
Aside from that, a project file like the following saved into the folder you're using for your project will also do what you want; just remember to use Project > Open Project... or Project > Switch Project... to open the file you've created so that Sublime will use it.
{
"folders":
[
{
"path": "."
}
],
"settings":
{
"trim_trailing_white_space_on_save": true
}
}

Related

Package name contains unexpecting level com.tmp

My Android Studio application called calendar contains package spectorsky, and it works. However, when I try to save the settings by
SharedPreferences calendarSettings;
calendarSettings = getSharedPreferences("calendarINI", Context.MODE_PRIVATE);
calendarSettings.edit().putLong("TimeZone",Double.doubleToLongBits(Riseset.timezone));
and then seek saved xml via Device File Explorer, I see my package on the strange level `com.tmp.spectorsky.calendar', see printscreen:
My file system on the hard disk does not contain tmp directory anywhere concerning this application. I see that the package names on other examples contain com level (somewhat like com.package.app), but no tmp domain is observed.
So, the question: why tmp level appears in my package name, and can (and should) I get rid it?
Level com.tmp was written it two places: in the manifest file AndroidManifest.xml and in the gradle (right-click on the app in project view, Open Module Settings, ApplicationID). Then, after cleaning the project, wrong com.tmp.... directory can be deleted from the Device File Explorer.

Double Filetype Extension: Correct Syntax Highlighting in Sublime Text 3

I am working with some .scss.liquid files and they always open as HTML Liquid, no matter how many times I set the syntax.
Update:
I tried open all with current extension as option, but unfortunately this affects files that are .js.liquid and .html.liquid as well.
Sublime Text allows you to apply settings on a per-language basis (actually, per syntax). One of the available settings allows you to map file extensions to the given syntax.
Assuming you're using a syntax named SCSS, Create an SCSS settings file in your User settings: /path/to/packages/User/SCSS.sublime-settings, then add the file extension setting:
{
"extensions":
[
"scss.liquid"
]
}
As you can see, it's a json file, and extensions is a list, so you can add as many file extensions as you need. Do not add the leading dot.
Caveat about the file name
The file name for the settings file must match the actual syntax name, including case. In this case it has to be SCSS.sublime-settings. Other examples include:
NAnt Build File.sublime-settings
Ruby on Rails.sublime-settings
Rd (R Documentation).sublime-settings
Java Server Page (JSP).sublime-settings
I found a relatively straightforward solution to this problem.
Install ApplySyntax
Create the following rules in ApplySyntax.sublime-settings -- User:
"syntaxes": [
{
"syntax": "SCSS",
"extensions": ["scss.liquid"]
},
{
"syntax": "JavaScript/JavaScript",
"extensions": ["js.liquid"]
},
]
Update: I now see there is no need for an extra package. Please see accepted answer and my video (in the comments) for tips on how to make it work.

Modify or extend default settings for a project

In a sublimetext3 project, is there a way to modify or extend, not replace, default settings?
To be specific, in a project I specify the paths of the folders to include in the project. Each folder has files and directories unique to that folder that I want to exclude using either folder_exclude_patterns or file_exclude_patterns; see documentation for Projects.
But as I understand this, these project settings replace not extend the default settings. What I would like, however, is to have a project setting that appends to the default pattern rather than replacing it. Is this possible?
Pseudo code that expresses what I would like to do:
"folders":
[
{
"path": "c:\\dir1",
"folder_exclude_patterns": default_folder_exclude_patterns + ["junk"]
},
{
"path": "C:\\dir2"
"folder_exclude_patterns": default_folder_exclude_patterns + ["old"]
},
]
If this is not possible, then I believe the only thing I can easily do is copy the default settings and replicate them for each folder item. Since I have multiple projects/folders and need to do this for file exclude, folder exclude and binary file settings, this will get tedious and be hard to maintain. Of course, this seems like it is ripe for a plugin, but that is not in the scope of what I am looking to do. (Of course if someone else has a plugin that does something like this, I would be happy to try it out! :-))
Unfortunately, due to the way Sublime is set up, higher-precedence settings replace lower-precedence ones, not supplement them. This is a good thing because many settings are either/or - what would you do if your user settings had "highlight_line": false while a project had "highlight_line": true, for example?
A plugin should be able to do the trick. sublime.Window contains the project_data() and set_project_data() methods, which allow you to retrieve and write project settings, respectively. You could add a "more_folder_exclude_patterns" key to each folder in your project with the additional patterns you would like to add to the defaults set in your Preferences.sublime-settings file. The plugin could then check if the "more" key exists, read both arrays, concatenate them, and write the result back to the .sublime-project file, erasing the "more" key at the same time. Finally, you could set up an event listener to run the plugin whenever you wanted - on save, upon loading a new file, etc.
EDIT
Here's a working example:
import sublime
import sublime_plugin
from copy import deepcopy
class ModifyExcludedFoldersCommand(sublime_plugin.WindowCommand):
def run(self):
proj_data = self.window.project_data() # dict
orig_proj_data = deepcopy(proj_data) # for comparison later
settings = sublime.load_settings("Preferences.sublime-settings")
fep = settings.get("folder_exclude_patterns") # list
for folder in proj_data["folders"]:
try:
if folder["folder_exclude_patterns"]:
break # if f_e_p is already present, our work is done
except KeyError:
pass # if it doesn't exist, move on to mfep
try:
mfep = folder["more_folder_exclude_patterns"]
new_fep = sorted(list(set(fep + mfep))) # combine f_e_p from
# Preferences and project,
# excluding duplicates using
# a set.
folder["folder_exclude_patterns"] = new_fep
del folder["more_folder_exclude_patterns"]
except KeyError:
pass # if mfep doesn't exist, just move on to the next folder
if proj_data != orig_proj_data:
self.window.set_project_data(proj_data)
class UpdateProjectData(sublime_plugin.EventListener):
def on_activated(self, view):
window = view.window()
window.run_command("modify_excluded_folders")
Save the file as Packages/User/modify_excluded_folders.py (where Packages is the folder opened when selecting Preferences -> Browse Packages...) and it should go into effect immediately. It will run each time a view is activated. It checks for the presence of a "folder_exclude_patterns" array in each folder defined in the current .sublime-project file, and if found it assumes everything is OK and passes on to the next folder. If that array is not found, it then checks for the presence of a "more_folder_exclude_patterns" array. If found, it does its magic and merges the contents with the existing "folder_exclude_patterns" array from your preferences (Default or User). It then writes a new "folder_exclude_patterns" array into the folder and deletes the "more_folder_exclude_patterns" array. Finally, it checks to see if any changes were made, and if so it writes the new data back to the .sublime-project file.

Why is Find in Files in Visual Studio Code OSX ignoring my search.excludeFolders setting?

Even with the default configuration, I still get tons of results in various node_modules folders when doing a workspace search.
Default setting:
"search.excludeFolders": [
".git",
"node_modules",
"bower_components"
],
I've even tried copying to my user settings and changing to several variants, such as "/node_modules", "/node_modules/", etc.
I've already seen the other post in vscode about this issue: How can I choose folders to be ignored during search? . This answer doesn't solve my issue.
I'm using Version 0.1.0 on OS X (commit d13afe1). Any chance there's a bug with exclude folders?
After reading again your question and trying it out, only now I notice that the search.excludeFolders values apply only to the workspace root. So, for a node_modules folder in your hierarchy, you would need to use:
{
"search.excludeFolders": [
".git",
"node_modules",
"bower_components",
"path/to/node_modules"
]
}
These preferences appear to have changed since #alex-dima's answer.
App -> Preferences -> User/Workspace Settings
You can choose custom settings that will apply to searches. For example, I am developing an EmberJS application which saves thousands of files under the tmp directory.
Picture of search before updating settings.
After updating the Visual Studio settings.
{
"search.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/bower_components": true,
"**/tmp": true
}
}
Note: Include a ** at the beginning of any search exclusion to cover the search term over any folders and sub-folders.
The search results are exactly what I want.
Picture of search after updating settings.

Visual studio export template replaces original projectname with $safeprojectname$

My project is a mvc4 project in visual studio 2013 ultimate.
I tryd to send my project by following the steps :
File > Export template > (leave all the options as default)
I get a zip that i unpack. If i open the unpacked solution and run the program i get alot of errors. It looks like visual studio replaced all the text that contained the projectname with $safeprojectname$. How can i export the project without visual studio replacing all the 'projectname' spots so that i can run my program.
I tryed creating a new project (console application) with no code in it, if i export it and import it i get the same message first i get :
Warning 1 Load of property 'RootNamespace' failed. The string for the root namespace must be a valid identifier. SvenEind
and after running i get
190 errors 31 warnings
I tryd importing http://www.asp.net/mvc/tutorials/getting-started-with-ef-5-using-mvc-4/building-the-ef5-mvc4-chapter-downloads and that worked for me.
So i guess the problem is in some kind of settings for exporting files.
replaced all the text that contained the projectname with $safeprojectname$
This is very much by design. You created a project template, a cookie-cutter for new projects. You are not supposed to do anything with the .zip archive. It should sit patiently in your "My Exported Templates" folder. Until the day arrives that you want to start a new project.
You then can pick the template instead of using one of the built-in ones that were preinstalled by the Visual Studio installer. Visual Studio prompts you for the project name. It then unzips the archive, copying the files into your new project directory. And modifies the files, $safeprojectname$ is substituted by the new project name you entered. You now have a good start for your new project, using the settings and assets that you saved earlier when you created the template.
Sounds like you had an entirely different use in mind, I can't guess at the intention from the question.
Hmmm. I got this error on Build:
The app manifest must be valid as per schema: Line 42, Column 18, Reason: '$safeprojectname$' violates pattern constraint of '([A-Za-z][A-Za-z0-9]*)(\.[A-Za-z][A-Za-z0-9]*)*'. The attribute 'Id' with value '$safeprojectname$' failed to parse.
So I grabbed the project name from the VS Configuration Manger and put it in the app manifest like this.
<Applications>
<Application
Id="CordovaApp.Windows10"
And the error went away and the project built. HTH.

Resources