Open Sublime project and respect .sublime-project file from command line? - sublimetext3

I have a project with a myproject.sublime-project file. If I open the project by opening this file in the Sublime Text UI, Sublime respects the exclusion rules in the file.
However, if I open the file in Sublime from the command line, it does not:
subl myproject.sublime-project
The excluded files and folders appear in the Sublime Text UI. The same is true if I do subl ..
Is there a way I can open this project from the command line, and have it respect the rules in myproject.sublime-project?
Here are the contents of the file, for reference:
{
"folders":
[
{
"path": ".",
"file_exclude_patterns": [
"server/site/*.js"
],
"folder_exclude_patterns": [
".sass-cache",
"node_modules",
]
}
]
}

Related

Visual Studio Code - how to add a vim editor command?

I'm trying to bind ":W" editor command to save the file just like ":w". I make a lot of this typos.
The vim plugin is: https://marketplace.visualstudio.com/items?itemName=vscodevim.vim
This settings.json code doesn't work:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": [":","W"],
"commands": [
"workbench.action.files.save"
]
}
]
Unfortunately this is not possible in vs code vim, but I ended up doing what bsaf suggested here and rebound : to ; so that I wouldn't accidentally be holding shift down while pressing w, which doesn't solve the problem you asked but it does solve the problem you mentioned in your post. You can do this by adding this to your settings.json file:
"vim.normalModeKeyBindings": [
{
"before": [";"],
"after": [":"]
}
]
You can still use : as normal, but now ; will also allow you to run editor commands.

Hiding files/directories from goto menu, but keep in project tree [duplicate]

For a large project with many dependencies e.g. in the node_modules/ folder, I noticed frequent CPU spikes because of Sublime indexing all the files in the folder.
I know I can hide files and folders using the folder_exclude_patterns setting, but I still want the folder to be visible in the sidebar.
How can I keep e.g. node_modules/ in the sidebar, but exclude it from indexing?
To exclude files from the index but keep them in the sidebar, use the binary_file_patterns setting in your User Settings, for example:
"binary_file_patterns": [
"*.jpg", "*.jpeg", "*.png", "*.gif", "*.ttf", "*.tga", "*.dds",
"*.ico", "*.eot", "*.pdf", "*.swf", "*.jar", "*.zip",
"node_modules/**",
"bower_components/**"
]
Make sure to copy the values from your Settings - Default preferences (here shown as "*.jpg" etc.), or you will start indexing binary files.
You can change your personal settings, in Preferences -> Settings - User, add:
{
"folder_exclude_patterns":
[
".svn", ".git", ".hg", "CVS",
"node_modules",
],
}
Sublime Text 3 now provides a way to exclude files and folders from indexing while keeping them in the sidebar:
"index_exclude_patterns": [
"*.log",
"node_modules/*"
]
On my project I observed the following improvement in the indexing status menu after applying changes:
Before:
index "MyApp" collated in 0.70s from 73934 files
index "MyApp" is using 15167488 bytes for 54234 symbols across 1357673 locations
After:
index "MyApp" collated in 0.00s from 137 files
index "MyApp" is using 61440 bytes for 730 symbols across 4763 locations
Doesn't work in ST3 (Build 3126).
You can show node modules folders in sidebar and hide files inside this way :
"file_exclude_patterns":
[
...,
"node_modules/**"
]
If you want to hide subfolders from each node module :
"folder_exclude_patterns":
[
"node_modules/*/**"
]
All files inside node_modules will be removed from search, but each node_module subfolder will be still visible in sidebar.
I thought binary_file_patterns wasn't working, because I am in the habit of right-clicking my top level folder and choosing "Find in folder". folder_exclude_patterns works with this but binary_file_patterns still searches everything - because the "Where" field overrides the setting.
So you can either use the menu option Find > Find in files OR right click-your top level folder, choose "Find in folder" and then delete the text in the "Where" field so it shows the placeholder text "Open files and folders".
Obviously you still have to add this to Preferences/Settings:
"binary_file_patterns": [
"node_modules/",
],

"$file" variable nor working with exec command

I want to set a shortcut to open my current file using an external program (in my case, Visual Studio).
I thought I could use the $file variable, available in the build system. So it I write:
{ "keys": ["ctrl+o"], "command": "exec", "args": {"shell_cmd": "\"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\devenv.exe\" $file"} }
I get in the Sublime console prompt:
Running "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" $file
As you can see, the $file variable isn't expanded to the pull path of the open file. Does anyone know what's the problem here?
Working solution for (but for OS X) was to use it like this:
{ "keys": ["super+shift+option+o"], "command": "exec", "args": {"cmd": ["open", "-a", "ForkLift", ""]}}

Keep Gnuplot window open when building from Sublime Text

I am using the gnuplot package from PackageControl in Sublime Text 3 on Windows. My gnuplot code successfully builds when run from Sublime Text, but if using a terminal that outputs the plot to a graphics window (such as the default wxt), the window appears and closes immediately.
Presumably there is a way to edit the gnuplot.sublime-build file to keep the plot window from closing, but I have been unsuccessful so far.
My Sublime Text build file for gnuplot currently looks like this:
{
"cmd": ["gnuplot", "$file"],
"working_dir": "${project_path:${folder}}",
"selector": "source.gnuplot",
"variants": [
{
"cmd": ["start", "gnuplot", "-persist", "$file"],
"shell": true
}
]
}
Unfortunately, the -persist has no effect.
I had this problem as well... I ended up just adding:
pause -1
To the end of my script.

Key binding. How to run a external script (external command/program) in sublime text 2 when pressing a key?

I would like to run a external python script (or external command/program) when I press a key on Sublime Text 2.
How can I do this?
Here is a solution:
Preferences->Key Bindings - User and put this in the file (overriding the [,] inside):
[
{ "keys": ["<your shortucut>"], "command": "exec", "args": { "cmd": ["<path to your script>"]} }
]
Where <your shortcut> as the name says is the shortcut (examples: F1, ctrl+shift+F1, etc.) and <path to your command> is the location of your command (examples: echo, /home/user/scripts/my_script.py, ls, etc.)

Resources