The normal mac behavior for command+shift+? is to open the help menu search, which is super convenient to do menu commands without a mouse.
Unfortunately a sublime text package I have installed has mapped that key binding to the settings menu. Here's the relevant section of the package Default (OSX).sublime-keymap file
[
{ "keys": ["super+shift+/"], "command": "open_settings" }
]
Based on Related to How to unbind a key binding in Sublime Text 2?
I went ahead and overrode their keybinding in my user keybinding. Here's my user Default (OSX).sublime-keymap file.
[
{ "keys": ["super+shift+/"], "command": "noop" }
]
This stops the package from open settings when I press the key sequence. Same behavior if I use unbound for the command, excluding the command files package keybinding. However, it doesn't bubble up to the Mac layer which opens the help search menu.
I can get things to work the way I want to by modifying the package's key binding file directly, but that's going to get overwritten the next time the package upgrades.
Is there a supported way to remove a keybinding without stopping it from bubble up to the operating system?
The only way to completely remove a key binding in a way that Sublime won't react in any way is to remove it from the sublime-keymap file. This is true whether you want to fully remove a file from the Default/Default (PLATFORM).sublime-keymap (there is one for each platform) that ships with Sublime to remove a default key binding as well as any that might be added by a third party package.
As long as the key remains in a sublime-keymap anywhere, Sublime will see it and try to do something with it, even if the key is bound to a command that doesn't exist such as noop (although that is a good way to block a default key from doing anything if that's your ultimate goal).
Editing the package file
One way to solve the problem is to directly modify the packaged file itself, as you've already mentioned. In most cases that would mean unpacking the related sublime-package file (which is just a zip file), modifying the content of the file, and then repacking it.
As you've already noted, that's not a good way to go because when a package gets updated, the entire sublime-package file gets clobbered away, so your changes will also get discarded.
Overriding the package file
A safer way to do this would be to create a package override file instead. This only works if the package in question is installed as a sublime-package file, which covers all of the packages that ship with Sublime as well as most third party packages.
To do this, you would create a folder in the same name of the package in the Sublime Packages folder, which you can get at via the Preferences menu item Browse Packages.... Once that's done, extract just the file you want to override and place it into that folder, and edit it as desired.
When Sublime loads packages from a sublime-package file, as it loads each file it checks to see if any similarly named "unpacked" files exist in the Packages/PackageName/ folder. If such a file exists, the version inside of the sublime-package file is ignored and the unpacked file is used instead.
This means that even if the package gets updated, since your unpacked version is still there, it will still be used and so your change will remain in place.
The easiest way to create such a file is to use the PackageResourceViewer package. You can use it's PackageResourceViewer: Open Resource command from the command palette to find and open the offending file. If you make changes to the file and save it, PRV will automatically create the override for you.
There are a couple of caveats to this process:
If the package in question is installed already unpacked in the Packages folder, you can't create an override. In this case there's not a lot you can do other than vigilantly re-modify the file when it updates.
Most packages won't fall under this restriction because few actually need to be installed that way (only packages that contain files that need to be exposed outside of Sublime need to be installed this way).
Note also that Sublime Text 2 only installs packages as unpacked, so in that particular case you also can't do this.
When a package override exists, it's always used in place of a packed file of the same name, no matter what. This has the unfortunate side effect that if the package update actually modifies the file that you're updating in any way, those changes are masked from you without warning.
Will the full caveat/disclosure that I'm the one that wrote the package, the OverrideAudit package for Sublime can warn you when this happens by checking every time a package gets updated to see if the version of the packaged file is newer than your overridden version so that you know this is happening and can take appropriate action.
Sublime Text 2 notes
Your question is tagging Sublime Text 2 and Sublime Text 3. In the case of Sublime Text 2, the information above about needing to remove a key binding completely in order to allow the OS to see it still holds.
However as far as I'm aware Sublime Text 2 doesn't support the idea of package overrides because it always installs all packages unpacked. As such the only solution in that particular case is to modify the packaged file and keep an eye out for changes.
At this point with Sublime Text 3 officially released there are not many compelling reasons to keep using ST2. If you purchased your license for ST2 sometime mid/late 2013 or later your license should be valid for ST3.
This is particularly important in that ST2 is no longer supported and as of High Sierra when Apple removed Python 2.6, various Sublime packages will now no longer work.
Related
When you save a project, Sublime Text will create a .sublime-workspace file. In this file, there is an array of buffers, and for each buffer there is a color_scheme property. This is set to whatever color scheme was chosen when the buffers and workspace were created.
I recently changed my theme and color scheme in my user settings file. How can I refresh all of my project's workspaces so that way it uses my new color_scheme provided in my user preference file without needed to edit each project's workspace file one-by-one?
Expanding on the answer given by Tot you can do this for all views in all windows that are open by using a nested list comprehension (remember this is Python so we can be pretty flexible):
[ v.settings().erase("color_scheme") for views in [ w.views() for w in sublime.windows() ] for v in views ]
This way you don't have to run the command in each tab individually.
The only way I found to reset tabs to user's chosen color scheme is to enter this in the console :
view.settings().erase("color_scheme")
This will reset the color scheme of the selected tab - unfortunately you'll have to do it for each tab. But it's still quicker than closing and reopening the tab.
I only have this issue with Sublime Text 3 on Mac OS X.
Source : https://www.sublimetext.com/forum/viewtopic.php?f=3&t=19310
P.S. : If you've just updated your color scheme file, you'll sometimes have to execute this command twice. Just type the up arrow in the console to write the last command again.
Windows 10 AppData-related Solution
Please make sure that you are in a similar situation as me before trying this solution (see below). Steps:
Note the language and package that the Error loading colour scheme reports (my case was: markdown and MarkdownEditing).
Go to your AppData directory (type %AppData% in file explorer address bar).
Open directory Sublime Text 3, or whatever your version is.
Open the .sublime-settings file that matches the language from step 1.
Remove any lines that refer to the package you noted from step 1.
Remember that this file should be a properly formatted JSON file when you remove lines manually. Save this file and restart Sublime Text.
Background
I've decided to post here in case some of the python script solutions didn't work for you and your situation is similar to mine. I'm using GitHub to sync my Sublime Text AppData (Windows 10), in order to keep my workflow settings the same on multiple machines. Recently, I noticed that when I uninstalled a certain package on one of my machines, I accidentally merged some configuration files for that non-existent package on my other machine. This resulted in a persistent Error loading colour scheme, in particular for me when changing syntax to markdown (the package was MarkdownEditing for reference).
Is there any way to disable Sublime Text 3 firing code completion, when cursor is inside single or double quotes:
This seems to be pointless behaviour and is a little bit annoying.
I'm using newest stable (3065) Sublime Text 3, with PHP Completions Kit plugin, if that matters.
So it turns out that your PHP Completions Kit plugin is probably to blame. I forked the code on Github if you'd like to follow along.
You can populate the auto-complete dropdown in Sublime by creating a JSON-formatted .sublime-completions file. Essentially, it's a long list of snippets with associated triggers, the names of which show up in the dropdown and are matched by a fuzzy search method based on what you type. The completions are all scoped so they only come up in the desired parts of your code: for example, you wouldn't want standard function names coming up when you're trying to define a class, etc.
Back to the plugin. For several of the completion files, the scope was built up using negative selectors: starting with source.php (the base scope for all PHP code), and subtracting unwanted scopes. Once analyzed by Sublime, the completions would show up anywhere except where they were explicitly denied. An example, from function.sublime-completions:
"scope": "source.php - variable.other - meta.function.arguments - support.class - entity.other.inherited-class - meta.use - meta.catch - comment.block.documentation.phpdoc"
So those were all the places the author didn't want these completions to show up. Unfortunately, in these several files, s/he forgot to include the string scope, so completions appeared when you were typing strings, clearly undesired behavior. Fortunately, the fix is easy: go through all the completions files, check the scopes for negative selectors, and add - string to the end of them. Now, they'll still work exactly the same as before, except the completions won't show up in any kind of string.
Like I said at the top, I forked the project here, and have made the necessary corrections. I've also submitted a pull request, so we'll see if/when that gets accepted into the main code base. In the mean time, feel free to clone my repo into your Packages directory:
Click on Preferences -> Browse Packages... to open up your Packages directory. Go to that directory via the command line, then run
git clone https://github.com/MattDMo/sublime-phpck.git "PHP Completions Kit"
This will clone the repo into a folder named PHP Completions Kit, overriding the one installed by Package Control. Keep an eye on the plugin's Package Control page, and when you see the Modified field change from 2014-09-05 (it's in the tooltip if you mouse over the text 3 weeks ago) to sometime more recent, check the repo to see if it was my pull request that got merged and a new version released, and then you can feel free to delete the new folder in Packages and just stick with the Package Control version, as I won't be keeping my repo up-to-date on any new modifications to the package.
Update
My pull request has been merged, and Package Control has been updated.
I use Sublime Text 3 in my company and I want to export all the settings, including packages and whatever, to use the same configurations in Sublime Text 3 I have at home. How can I do this?
PS.: I use Windows 8
The best way is to sync the User directory, there are multiple available ways to do this - dropbox, git and manual ways.
Installed packages are registered in Package Control.sublime-settings, which is located in the user folder as well, thus, it does not require you to sync anything besides that. A pretty good guide to syncing can be found here.
You also may wish to check out this package.
For me (Windows installation) transferring all the content from old installation - AppData\Roaming\Subime Text 3, to new installation - AppData\Roaming\Subime Text 3, does the job. All the packages and UI settings are transferred and are working correctly.
None of the manual efforts are needed now (I think). Both sublime text (ver 3) and visual studio code (if anyone cares) have extensions that do this for us.
For VS Code -
https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync
For ST3 -
https://packagecontrol.io/packages/Sync%20Settings
With a few clicks like generating token and configuration, one should be able to easily port the settings from any machine (Win, OSX, Linux) to any machine.
You can try this plugin PackageSync. It can package your settings and packages into a zip or 7z file, then, you can import them on another machine.
As an aside an easy way to locate the 'User' or 'Sublime text {2/3/etc}' folder regardless of OS is to:
Open go-to-anything and just type: 'us'
From the available options select 'Preferences: Package Control Settings - User’ to open that file.
Right click on the file and make the selection to open the containing folder (Mac: reveal in finder)
Navigate back up to the parent folder Sublime Text 3 (or whatever version number you are on)
Copying this folder and replacing the Sublime Text 3 folder in a fresh Sublime install with this one should install all packages and replicate any other settings you have.
source
"If you want to sync settings across machines, the best way to do so is to just sync the Packages\User\ folder. This contains all customized settings, and if you are using Package Control, it includes a list of all installed packages. If Package Control sees that an installed package is not present on the machine, it will automatically install it the next time Sublime Text starts."
PS: if I am not mistaken the author of this post is the key developer of sublime.
I'm using TortoiseHg v2.2.1 with Mercurial 1.9 in WindowsXP. How do I configure TortoiseHg to view a file based on the application Windows has associated with its extension?
For example, if I have a .docx file in the repository and I'm looking at its revision history, I'd like View at revision... to open the selected revision in MS Word. Likewise for other binary file types like ppt and xls, which I can't view using the default text editor or kdiff3.
Can I leverage that Windows already knows what program to use to open certain types of files or will I have to manually configure each file type of interest within the Tortoise config files?
I've found several SVN scripts in the TortoiseHg\diff-scripts folder that look like they solve a similar problem for diffing binaries rather than simply viewing them, but those don't seem to be activated and I'm not sure what if anything I need to mod in the MergePatterns.rc or Mercurial.ini files to make this all work.
To make "View at Revision" use whatever program is associated with the file's extension, try this trick: In the "Global Settings" in the "TortoiseHg" section, enter start "" as "Visual Editor". Note the empty "". This is necessary so that start will not use the file name, which gets passed in quotes by TortoiseHg, as the window title.
XCode2 had this beautiful feature: you put the cursor on a line with a #include <file> and execute the open-quickly command (command-shift-D) and it would open the file. I can't get it to work for me in XCode3.
I have something like this
#include <folder/subfolder/HeaderFile.hh>
and when I put the cursor on this line, and open the open-quickly dialog, it automatically fills the search window with
folder/subfolder/HeaderFile.hh
but doesn't find anything. If I then remove "folder/subfolder/" then the dialog will identify HeaderFile.hh and I can open it up. But this extra deleting is so much slower just the three-key command-shift-D opening I was used to with XCode2.
If I give it the full path to this file in the search window, then it finds it:
/Users/andrew/myproject/src/folder/subfolder/HeaderFile.hh
this path will find the file. Again, I don't want to spend all my time typing out the full path.
I created this project as an external build system, and I think that's related to the problem; the xcode project lives in
/Users/andrew/myproject/xcp_dir/
and I want it to search in the "../src/" directory so that the partial path I give it (which is already present in the #include) will match the file I want to open. In XCode3, I had to create the project in the xcp_dir directory; in XCode2, I could create the project directly into the existing myproject/ directory -- maybe that's why the search is failing?
I read on a previous thread (which never answered the question) that I should set the HEADER_SEARCH_PATHS option. I tried this (setting the option to /Users/andrew/myproject/src) but it did not work.
I don't have any sense of what other options (like the HEADER_SEARCH_PATHS option) are availalbe, so if you know which one I have to set, I'd love to hear it.
Since this is an old question I'll answer it for Xcode 4 instead of 3.
As far as I know Open Quickly doesn't use anything like a search path. It seems to have use the project's codesense index and will show results from that. Querying the database doesn't have an notion of file paths, so the workflow you describe just won't work anymore.
However that's okay, because there's a better solution: Just ⌘+click on the include line and the appropriate file will be found using the same rules as the compiler uses, and opened. If you want to open the file up in an assistant, another tab or window, you can use ⇧⌘+click instead, and you'll get a little UI for easily selecting where you want the file opened.
You can also use these shortcuts to go to definitions for any identifier.
If you don't want to use the mouse you can use the command "Jump to Definition" which has the shortcut ⌃⌘J, or ⌥⌃⌘J to open the definition in the assistant editor. This also works for both normal identifiers and #included files.