Does Sublime Text (2|3) have an API method or some way of determining if a shortcut or hot key sequence has already been assigned? I have lots of plugins and macros installed, and when making new ones it can be difficult to determine what key sequence to assign it to so I don't conflict with something else. Key bindings can be assigned in .sublime-keymap files in Packages/Default, Packages/User, and whichever plugin wants to assign them. To make things more complicated, I work on three different OSes, and there are different keymaps for each platform. Do I have to keep manually searching all the keymap files myself, or is there a better way to do it?
You might try installing and using FindKeyConflicts.
You can also open a console ctrl + ` and enter sublime.log_commands(True). You can then enter your shortcut/key sequence and see what, if anything, is bound to it.
Related
I found a plugin (sublimelinter) for this task but it is for specific languages.
Do you know a way to highlight/detect unique word in Sublime Text for all programming languages ?
To be clear I'm looking for a way to detect unused variable via a plugin wich detect unique word in a code since a unique word is generally also unused (It is not totally true but still it is not a problem if it wrongly detects few words such as "static","serial" and so on for c++. Ideally I should be able to list words to exclude).
Important : I do not want a solution in which I have to compile my code.
There is plugin SublimeClang. It provides auto complete suggestions and error / warning reporting.
Are there any plugins that would do this? Let's say you highlight a code block, when you press undo, it undoes the last change with in that code block?
I've done a lot of digging into Sublime's internals, and I don't think this is possible. Commands (processes executed when you select a menu item or hit a key combination) are implemented in one of two ways: either in Python, making use of the API, or internally in C++ and compiled directly into the executable or a library. If a command is implemented in pure Python, such as delete_word (source in Packages/Default/delete_word.py), you can edit the source if necessary or take portions to use in your own code. However, if a command is implemented internally, there's not much you can do to modify it, unless it has options that are documented somewhere. You basically have to use it as-is.
Which brings us to the undo/redo commands, and the edit history. As far as I can tell (since Sublime is not open source - yet), this entire functionality is completely implemented internally, with only the command names exposed. I have been completely unable to find any way of viewing or accessing the actual changes made to the undo/redo stack. The command_history() method of the sublime.View class accesses the commands in the undo/redo stack, but not the actual changes they made.
So, all of this is to say that one could not likely make a plugin that could access the change history of an arbitrary selection in Sublime. One of the major issues (aside from the fact that the change history of the view is not accessible) is that the text you select now might not correspond to anything at a certain point in the history - it might not exist, or could have been altered so fundamentally that it would be essentially impossible to identify which changes should be associated with the selection, and which not. I have never heard of a similar feature in any other editor, most likely for that exact reason.
I am having lots of fun playing with the new CDE, BUT, I have not been able to find much documentation on it.
Does anyone know the default shortcut key bindings? And secret commands?
I understand it is based off of the Ace Editor, but it seems to not follow the default key bindings:
https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts
The one I need NOW is Find and Replace, it is not CtrlR, which appears to be RUN.
I know creating and maintaining documentation is dull, but at some point a simple link to basic features would be nice. Good thing to do while is super cold out right now (Canada).
CDE uses the ACE editor. Here are the default key bindings for it:
https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts
It's complicated...
A cross-OS way to get to Replace in CDE is to press Ctrl-F (Command-F on a Mac) twice. Every subsequent press will alternate between Find and Replace. That's the default Ace behavior, as can be seen it its own proof-of-concept "Ace kitchen sink" page.
I'm not even sure whether Ctrl-R is up-to-date: I've checked a couple of other IDEs that use Ace, and it doesn't work there (Ace's own Cloud9, Zed, ...).
Ctrl-H works on everything except Mac. Unfortunately, on a Mac, its equivalent Command-H is reserved by the system and hides the current window.
I've filed a bug against Chrome Dev Editor to do something about it: https://github.com/dart-lang/chromedeveditor/issues/3803.
Currently, there is no way to see the shortcut bindings in CDE: it's bad, and we (the CDE team) are going to fix that sometime soon.
Are there keyboard bindings to the refactoring commands in MonoDevelop?
A direct answer: Yes, there are.
A bit more useful answer: depending on what you're looking for, quick examples:
Alt+Return is quick fix (given you've got source analysis turned on)
Alt+Insert is code generation (properties, overrides, etc.)
F2 is rename
And, in case you're not aware, all the refactorings for the symbol you got under your cursor are available in the right-click context menu (available by pressing the relevant keyboard key, so it also kind of counts as a keyboard binding ;) )
Apart from that, you can look up and/or change all (or at least many, I'm not exactly sure) the bindings in Options > Preferences > Key Bindings.
Does the above answer your question?
It depends which version of MonoDevelop you are using. With the late 2.x series then there were individual key bindings for "Create Method", "Extract Local Variable" and a few others (see the documentation).
Renaming (including renaming files in the explorer view and renaming variables, classes or anything else in the text editor) is a separate key binding under the "Edit" section and defaults to shortcut key F2.
As of v3.x, these key-bindings seem to have disappeared. Edit > Preferences > Key Bindings still has a "Refactoring" section, but it now only lists Import Symbol, Quick Fix and Show Fixes (none of which I'd necessarily even call refactoring - they're more code completion features). Instead, the refactoring methods are all available as "Quick Fixes" (default: Alt+Enter when Source Analysis is turned on from Edit > Preferences > Other > Source Analysis).
The reason for the change appears to be that the refactoring mechanism has been overhauled and now relies on source analysis, but this isn't quite perfect yet and so isn't enabled by default. As they're part of the Quick Fix system then they've not been given separate key bindings (as I believe there are more of them now).
For me, Source Analysis menu is:
Tools>Option>Source Anyalysis (Under Text Editor) > Enable
Well it does make some changes to the Editor screen, it doesn't really give me useful suggestion for correction (auto fix) like Eclipse, regardless of whether I've press Alt+Enter.
Since MathWorks release a new version of MATLAB every six months, it's a bit of hassle having to set up the latest version each time. What I'd like is an automatic way of configuring MATLAB, to save wasting time on administrative hassle. The sorts of things I usually do when I get a new version are:
Add commonly used directories to the path.
Create some toolbar shortcuts.
Change some GUI preferences.
The first task is easy to accomplish programmatically with addpath and savepath. The next two are not so simple.
Details of shortcuts are stored in the file 'shortcuts.xml' in the folder given by prefdir. My best idea so far is to use one of the XML toolboxes in the MATLAB Central File Exchange to read in this file, add some shortcut details and write them back to file. This seems like quite a lot of effort, and that usually means I've missed an existing utility function. Is there an easier way of (programmatically) adding shortcuts?
Changing the GUI preferences seems even trickier. preferences just opens the GUI preference editor (equivalent to File -> Preferences); setpref doesn't seems to cover GUI options.
The GUI preferences are stored in matlab.prf (again in prefdir); this time in traditional name=value config style. I could try overwriting values in this directly, but it isn't always clear what each line does, or how much the names differ between releases, or how broken MATLAB will be if this file contains dodgy values. I realise that this is a long shot, but are the contents of matlab.prf documented anywhere? Or is there a better way of configuring the GUI?
For extra credit, how do you set up your copy of MATLAB? Are there any other tweaks I've missed, that it is possible to alter via a script?
shortcuts - read here and here
preferences - read http://undocumentedmatlab.com/blog/changing-system-preferences-programmatically/
At the moment, I'm not using scripts, though this sounds like a very interesting idea.
Unless there are new features that you also want to configure, you can simply copy-paste the old preferences into the new prefdir. I guess this should be doable programmatically, though you might have to select the old prefdir via uigetdir. So far, this has not created major problems for me. Note also that in case of a major change in the structure of preferences, any programmatic version would have to be rewritten as well.
I'm adding paths at each startup, so that I don't need to think of manually adding new directories every time I change something in my code base (and I don't want to have to update directory structures for each user). Thus, I also need to copy-paste startup.m for each installation.
If I had to do everything manually, I'd also want to change the autosave options to store the files in an autosave directory. If I recall correctly, Matlab reads the colors and fonts from previous installations, so I don't have to do that.