How to bind numeric keypad keys in TextMate? - macos

I often use TextMate on a desktop Mac with a full (old-style) Macintosh keyboard with a full numeric keypad. I'd like to be able to bind menu item keys, macro key triggers and other actions to some of those numeric keypad keys.
I understand I can do this for some Cocoa (?) text editing commands in a ~/Library/KeyBindings/DefaultKeyBinding.dict file, but for Macros the TextMate dialog box doesn't distinguish between numeric keypad and main keypad keys with the same name. Ditto for the OS/X keyboard shortcuts preference pane used to change TextMate menu item keys.
Should I be trying to customize some of the core bundles instead?
Any advice much appreciated,
Stu

I understand I can do this for some Cocoa (?) text editing commands in a ~/Library/KeyBindings/DefaultKeyBinding.dict file
This is the key. TextMate does use this file, but in addition it has its own version that may be used to override settings or provide unique actions. You can even call some TextMate functions (selectors) directly through this method.
I recommend copying the default version from /Applications/TextMate.app/Contents/Resources/KeyBindings.dict to ~/Library/Application Support/TextMate/KeyBindings.dict and modifying it there.
Unfortunately, calling Bundle macros is a challenge... but I think it may be possible through some clever combinations of commands...
("insertText:"," keypad1.sh","selectWord:","executeCommand:")
Then, if you add into your source bundle the default values of the commands (in Support/bin) --- keypad1.sh returns 1... --- you can have customized commands in the Bundles you're interested in modifying.
I haven't tried this, but I think it may just work...

Related

Mac: Disable Keyboard-Shortcut for symbol

On my mac, typing Option-Shift-R in any text field in any program inserts a "‰" character. The problem is that I use Option-Shift-R as a special shortcut in another program (PyCharm), and whenever I use this key it both executes the action in pycharm and types the character, which is annoying.
Given that I've never once needed the "per-mille" symbol in my life, is there a way on mac to disable this shortcut? There seems to be no option for it in the "Keyboard -> Shortcuts" menu.
It is your keyboard layout that's producing "‰" when you press Option-Shift-R. (It's also what produces "A" when you press the A key, and everything else.)
You can try switching to a different built-in keyboard layout using System Preferences > Keyboard > Input Sources, but you probably won't find one which produces nothing when you press Option-Shift-R.
So, your best bet is probably to create a custom keyboard layout and use that. There's an app called Ukelele that can help create such custom keyboard layouts. I haven't check recently, but I'm fairly sure it can create a new one by copying one of the built-in layouts, which you then tweak just a bit so most things work just as you expect.

Editing meta shortcut on nano text editor

Is there any option to change the meta M- shortcut on nano text editor?
Im working with a Mac, and I wanted to change the meta shortcut for comfort reasons. I'm actually using the esc key but will love to change it to my preference.
You can rebind individual keybindings by editing your ~/.nanorc file to include keybindings. Unfortunately, nano only supports ^, M- and F as modifiers, so it would be difficult (not to mention tedious) to fit all M- keys elsewhere.
Instead, it might be simpler to rebind the key in your terminal program, or use an external hotkey remapping program. I have no expertise with the latter on Mac, but you could start looking here.

Custom key for multiple cursor in VSCode

In VS Code you need to use alt to set multiple cursors. Is there any way to change it to, maybe, ctrl? Using alt really annoys me as it's less comfortable to me and it always toggles menu bar which I hid on Windows:
photo
Or maybe is there any other solution, maybe to change key that toggles menu? I couldn't find any useful shortcut entries in shortcuts config of vs code.
It is not currently possible to customize mouse shortcuts, the feature request for that is here https://github.com/Microsoft/vscode/issues/3130
It's actually completely unusable on most Linux distributions as it's an OS-level shortcut.

Unable to use Control key as the key equivalent for an NSButton in a xib file

I tried to use Control-Command-Whatever Alphabet as the key equivalent for an NSButton. Xcode interface builder doesn't allow me to do that. I tried editing the xib file in an external editor, adding control="YES" into the <modifierMask> node. Once I open the xib file in Xcode, Xcode deletes control="YES" that I added previously. The only workaround seems to be doing it in code.
Is there any reason Xcode disallows using Control in key equivalent for an NSButton? Should I also avoid doing it in code if it may become a problem?
I am using Xcode 6.1 on Yosemite.
From the human interface guidelines:
As much as possible, avoid using the Control key. Because the Control key is already used by some of the universal access features—as well as in Cocoa text fields where Emacs-style key bindings are often used—it should be used as a modifier key only when necessary.
So, while the behavior of Xcode isn't very nice in this regard, it is probably just trying to enforce the guidelines. As you rightly say, you can work around it easily enough in code.

How to specify key bindings in a dict file inside Cocoa app bundle?

(This is not a question about KVC/KVO and key-value bindings.)
I'm writing an application with a "tools" panel. Every tool can be selected using one-letter key (like "M" - "Move tool"). Tool can be selected even when there is no main window and the tools panel is not selected (not being "key").
Docs say that raw key events are not propagated to the app delegate and document controller (so I cannot rely on onKeyDown since it should happen in a WindowController). But "action events" (keys bound to a selector) are sent to the app, app delegate and document controller.
I know two ways to set such global bindings: through NSMenuItem key equivalents in Interface Builder or using ~/Library/KeyBindings/DefaultKeyBinding.dict file (which specifies global bindings for all apps).
Menu items approach is not good because I don't want to pollute my menu with commands which can be triggered from the tools panel.
I would like to set such bindings programmatically or specify them in a bundled KeyBindings.dict like Xcode and TextMate do.
However, I couldn't find docs or examples how to name such dict file and how to connect it to the app. Xcode uses PBKeyBinding.dict filename, TextMate uses KeyBindings.dict. There's no option for Info.plist to tell app to read the dict file.
Does anybody know how this could be done?
Thanks.
The documentation says this isn't supported. So, even if you get it working, it could break in a future version of Mac OS X.
I suggest putting all of the tools into a Tools menu. Redundancy is not inherently bad, and a menu could be more easily navigable by people with poor vision, and would serve as a quick reference for those not yet familiar with your tool icons.
If a Tools menu really is pointless, you can set the Hidden property of the Tools menu item (whose submenu is the Tools menu). This way, the Tools menu item is still in the main menu (menu bar), and so should still associate its key bindings with actions, but it is not visible to users.
In fact, this library does what I need:
http://github.com/carpeaqua/SGHotKeysLib
It uses RegisterEventHotKey function (requires linking with Carbon framework).

Resources