How do I use Fish's Alt bindings using Kitty on macOS - macos

I acquired a macOS machine for the first time, and I can't figure out how to use commands such as alt+E to open the current command in $EDITOR.
I don't want to remap the ⌘ key to alt system-wide, but I can't figure out how to the remap in either Kitty or Fish.
Why is the fish binding not working in mac os? is a relevant question but the answer there only applies to iTerm2.

Kitty allows treating ⌥ as alt with macos_option_as_alt. So I've put
macos_option_as_alt yes
into kitty.conf and started using ⌥ as my alt replacement on macOS.
It seems that it's discouraged on macOS to reuse ⌘ as a modifier.

By pressing ⌘+e, I found out that the shell gets "[101;9u", so I've decided to create a custom binding:
bind "[101;9u" edit_command_buffer
This way I get the alt+e equivalent on macOS.

Related

How do I rebind the Mac key shortcuts?

I am currently using a new Mac notebook. I was used to Unix before and now I would like to change the keystrokes so it is more like Unix. For example, when I press Alt Gr + ? it gives me the \ on Unix. But on Mac, I have to press Alt + Ctrl + 7 to get the backslash \.
How can I permanently rebind the keys, so it has the same outcome like Unix/Linux ? I would love to change it in a simple way, if that's possible. Thank you
This is possible with Karabiner-Elements, for example.
You can also search if existing rebind configurations are available for download.

How to remap "copy" shortcut in Xcode

I am trying to tune the key bindings in Xcode (version 8)'s preference.
Most of the keybindings can be remapped without a problem, except the Copy(Edit Menu) command.
When I am trying to map the copy command to Option+W key combination, Xcode does not allow it and show warning:
Modifiers are reserved for alternates.
Is there a way to bypass this restriction? For example, are there any copy commands other than Copy(Edit Menu) that functions similarly? Or are there any hotkey script either at MacOS level or Xcode plugin level that can remap a keybinding to another?
(I am trying to map the copy command to Option-W because I have got quite used to this key from Emacs. )
Thank you.
On Mac OS, Option-W is a typable character. It cannot be a hotkey. Hotkeys must include Command or Control.

How can I modify the control/option/command key mappings in the IntelliJ's Emacs keymap?

GNU Emacs on Mac OS X, by default, uses the control key as CTRL, and the command key as META. This drives me crazy, because my MacBook Pro contains only a single control key on the left, while I'm used to having a control key on both sides of the keyboard.
With my GNU Emacs installation, I was able to modify the variables mac-control-modifier, mac-command-modifier, and mac-option-modifier so that command acts as CTRL and option acts as META.
How can I accomplish the same thing in IntelliJ IDEA? It's easy to select "Emacs" as the keymap, but I don't see any way make a similar remapping of CTRL and META. I know I could remap these keys globally in the OS, but I don't want to do that. I also know I could go in to each and every action and individually modify them, but that seems like a poor solution.
It's may be not the easiest solution but you can open the resources.jar (/Applications/IntelliJIdea.app/lib/resources.jar on MacOS) file, locate the Keymap_Emacs.xml (in idea directory) copy and modify it.
And then you can create a new keymap in IntelliJ for updating it with the new content (~/Library/Preferences/IntelliJIdea90/keymaps on MacOS).
That way you can change all your keymap without changing each action individually.

Why is so complicated to remap Esc to CAPS LOCK in Vim?

I saw the vim wiki tips and it says that in order to remap Esc to CAPS LOCK you have to edit the following windows code:
REGEDIT4
[HKEY_CURRENT_USER\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00
Is it possible to remap Esc to CAPS LOCK by only adding or modifying lines in the _vimrc?
I recommend that you use AutoHotkey for this.
You can do a per-application hotkey change:
SetTitleMatchMode,2
#IfWinActive,VIM
CAPSLOCK::ESC
return
#IfWinActive
CAPSLOCK::CTRL
return
This script, for example sets caps to escape in vim, and control everywhere else.
There's no vim key identifier for the capslock key, so you have to do it with a scan code.
It would be like trying to map the ctrl key or the shift key to something - those keys don't do anything by themselves, they are key modifiers, so they can't be trapped the same way.
The mapping has to be done at the OS level instead of vim, so the complication comes from the OS. For example, on my Ubuntu machine I have the following in ~/.Xmodmap:
! Esc on caps lock
remove Lock = Caps_Lock
keysym Caps_Lock = Escape
However, I don't think the REGEDIT script is so bad. It's kind of ugly, but it's only two lines!
Also you can try this: SharpKeys.
I swaped CapLock and Esc with it.
You could also use Ctrl-C to escape (Available at least in vim). Which is what I normally use. I commonly swap control and capslock, though, and have done so through registry settings in windows and keyboard conf in ubuntu.
Edit: as #mMontu kindly notes, Ctrl-C is more brutal than Esc: As stated in this appropriate question,
vim isn't going to bother checking if you just wrote part of an
abbreviation, and it isn't going to run the fancy auto commands your
plugins have set up for every time you leave insert mode
I hadn't noticed because my vimming is not so advanced yet.
Another alternative that worked well for me was to use the instructions found in
this website
Essentially: Install Microsoft's Keyboard Layout Creator, then edit its source code to allow remapping of CAPS LOCK and create your own custom layout.
Remap CAPSLOCK to ESC and CTRL on Windows
A very nice tool that I've already described in this answer gives you the possibility to remap CAPSLOCK to both
to ESC (when pressed alone) and
to CTRL (when pressed with other keys)
Just use this little piece of open source software by ililim.
You do not need Admin privileges for this and ESC and CTRL are still working as expected.
I use it to enjoy convenient CTRL + anything presses without hurting my pinky and to toggle modes in Vim that I use via ssh in MobaXterm. For installation just follow this description.

Using the ALT key on Komodo for Mac OS X

I am using the Emacs keybinding on Komodo IDE where Komodo uses the command key for "Meta" by default. So you press Command-X when you normally press Alt+X for Emacs on Linux.
I want to use the actual Alt key .. so when I tried to assign Alt+K, Komodo informs that "This key combination is not available" (see screenshot below)
Komodo Preferences Dialog screenshot http://dl.getdropbox.com/u/87045/permalinks/komodo-alt-key.png
How do I use the Alt key in Komodo? Is it possible?
On the Mac the Option/Alt key is used to quickly enter non-ASCII characters.
Komodo provides a few bindings involving control keys, like Alt+Return to
edit a file's properties, but it stays away from the Alt/Option key for
the most part.
I tried binding [Go to file...] to Cmd+Alt+K. The preferences dialog
accepted it (although it said it was first bound to Cmd+¬, and later said
it was bound to Cmd+Alt+Û, both of which gave me the feeling that
the binding would fail to work. There have been Mozilla bugs dealing
with inconsistencies in keybindings on OS X, and we're seeing that here.
Komodo will also let you create keybindings using combinations of
the Command, Control, and Shift keys -- I would stick with those,
and leave the Alt key for entering non-ASCII characters.
One can workaround this behavior using ControllerMate or a similar tool:
Create a new Driver Configuration for your normal keyboard
In that configuration, swap the Option and Command keys
Disable this new configuration
Create a new ControllerMate page
Add an Application Block to that page which only triggers when Komodo IDE is running in the foreground
Add a Properties Block connected to the Application Block which enables your Driver
Configuration.
Thus, when Komodo IDE is running in the foreground, ControllerMate swaps
Command and Option, giving you the Meta behavior you get everywhere else in OS X.

Resources