Mac OS X Terminal [Use option as meta key] overrides backslash in spanish keyboard [closed] - macos

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I check "Use option as meta key" checkbox in Mac OS X Terminal, because I like to use emacs way of moving between words: M-f & M-b.
But if I do that, I can't get the backslash (Option + º; i.e.: Option + key-at-the-left-of-1-in-spanish-keyboard).
If I uncheck it, then I can input the backslash, but I don't have M-f & M-b.
Is there a way to get both?

The escape key works as a meta key by default; no need to use option as the meta key (other than its more convenient location).

Not a great solution, but XTerm (running in X11 on OS X) can use CMD as the Meta key.
You might also have some good results from KeyRemap4MacBook.
Just as a side benefit, XTerm should also give you proper terminal mouse interaction, e.g. in Emacs or ncurses based apps.

You will most likely run into a lot more problems with that setup, because Mac OS uses "Alt" as a modifier in a lot of shortcuts. But anyway, including the following line in your ~/.bash_profile will send a backslash if you enter the unicode character "∫" (which is E288AB):
bind '"\033\xE2\x88\xAB"':'"\\"'

You could customize the keyboard map to use a different key for entering backslash. Look in
Preferences > Settings > [profile] > Keyboard
For example, you could map Control-F1 to backslash.
Note that the default keyboard map maps Option-Left/Right Arrow to M-b/f, so you could use those instead of using Option for Meta (you’d have to get used to using the arrow keys instead of b and f, but I’ve never been able to get used to using b and f and prefer the arrow keys).

I had the same issue. This is how I solved it.
I replaced the built in terminal with iTerm2, which also gave me a few other nice features. To get a sane Meta-key i did the following:
For the profile I wanted to use I checked "Alt sends +Esc", which gave me back a sane Meta-key that works in Emacs, Bash and others. However, I did lose the backslash key. So, to get it back and added a binding in the profile that does "Send text: \" and then I bound it to my backspace key combo (Shift-Alt-7, I'm Norwegian).
Now I have M-f, M-b in Emacs, M-. in Bash and I'm able to send backslashes. I also have a "Visor shell session" that I can have slide down by pressing another key combination.

This is years late, but for people coming across this page whilst searching for a solution, as I did, I have decided to build one myself.
It is a simple status bar app that runs in the background and rewrites all left-Alt + $KEY key events to two key events in rapid succession, Esc, then $KEY; however, it only does this if Terminal.app is the focused application.
You can find it here at https://github.com/habibalamin/Metalt.

Related

Assigning special characters to keyboards permanetly [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
Is there a way in Windows 10 and/or Ubuntu to set new special characters in my keyboard?
I'm using a notebook, so I don't have Num Pad (or maybe I do but don't know yet). I have some characters that are fairly important, and I don't know how to type ALT+xxxx without the regular Num Pad. Googling for these characters every time is very cumbersome.
For instance, the left arrow character ←, which is assigned as Alt+2190.
Is there a way to type it directly in the keyboard without the regular Num Pad, or maybe a code or software I could use to set it.
When I say Windows 10, think Notepad, but it could also be on OneNote or a browser, if there are an easier way on those.
Thanks!
Ubuntu has keyboard shortcuts directly in settings. For Windows you can look into the third party app AutoHotKeys for keyboard shortcuts.
Also, try this answer for your numpad issue.
I found my own solution: how should I proceed with this question on Stack Overflow?
The answer was it the Wikipedia entry Unicode Input:
Some Windows' software accept the Alt + x solution:
Open the Wordpad¹ software (it should come by default on Windows 10).
Type the plain Unicode hex code in your text. Just the hex code, like 2190 for ← or f1 for ñ, no need for the U+ or anything before it.
Press the left ALT key plus the x character - Alt + x.
The text should automatically change the hex code to the sign you want.
Copy and paste the symbol into whatever you want it.
Not the perfect solution, but it is still better
¹ This may only work in specific software programs. It worked on Word, Wordpad, OneNote and Outlook, but not the simpler Notepad, neither Office online.

Alt key when navigating in console

In Ubuntu when using Alt modification key I can move between words using left/right arrows. But in OS X (iTerm2 actually) when pressing this key combination I get [D symbols. Do I need any additional libraries to make it work or how can I accomplish this for comfortable navigation?
Seems like this post cover how to deal with this issue. Will try it.
Also, similar Stack overflow question here

How to disable generating special characters when pressing the `alt+a`/`option+a` keybinding in Mac OS (`⌥+a` )? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
There is a behavior in my mac that I'm trying to disable.
When I'm in any text editor and typing a key combination using the alt/option+any letter, the output will be special characters.
For example:
the combination alt+a will generate å.
the combination alt+x will generate ≈.
I want to cancel this behavior.
I'm a programmer and when I use my code editor I want to map some keybinding (keyboard shortcuts) to the alt key (⌥+a for example) but when I do that it doesn't execute because it generates the special characters.
I guess that the special character has a priority over my code editor shortcuts.
Do you know how can I disable this default behavior?
Thank you
You can create a custom keyboard mapping with option-letters all set to BLANK using online tool from this webpage. You can create a custom mapping in several clicks out of almost any keyboard layout. Proved to work on MacOSX 10.7+ with IntelliJ Idea, Php/WebStorm, NetBeans, Eclipse.
Select "Set blank for option key" radio in the form, submit the form, and download a patched keyboard layout with "option" key feature disabled. I'm sharing the working file for standard US English keyboard layout:
MacOS <= 10.10
MacOS >= 10.11
After enabling this custom mapping, if you type a letter with "option" key pressed, nothing is printed to text output. But, the "option key press" is triggered by OS, and detected by your IDE. So you get exactly the same behaviour as you have for other command keys!
Download the key mapping file My Layout.keylayout.
Move it to ~/Library/Keyboard\ Layouts/
Open System Preferences -> Language Input Methods (or Keyboard -> Input Sources)
Go to Input Sources -> (hit +) -> Select Others
You should find My Layout in the list and select it.
Step 4 can change slightly across MacOS versions. Please be patient to find keyboard layouts list in the settings.
Here are detailed steps to Sebastian Zaha's answer. (I ended up fumbling around a bit before I got this working).
(Alternatively here is a ready made file by me)
Download Ukelele
You can run it directly from the .dmg file
File -> New Based On Current Input Source (I had US selected)
Click Modifiers button
Select each modifier from list that have Left Down or Right Down in the Option column. (There could be some like Either Down OR Up too, but AFAIK you can leave those.)
Press the minus button for each like this
Go to Keyboard menu -> Set Keyboard Name
Change the name somehow to make it easier to identify
Go to File -> Save as
Save to ~/Library/Keyboard\ Layouts/ with suffix .keylayout
Log out from your Mac OS account
Log back in
Go to System Preferences -> Keyboard -> Input Sources
Hit the + button -> Others -> Your new layout should be available
Add the new layout
Possibly leave original keyboard layout too and configure some nice way to switch
I was having the exact same problem, in the exact same IDE.
The solution to this is to download Ukulele from here:
http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=ukelele
In the application you can create a new keylayout using File -> New from current source. Pressing Option will show you in the place for Option-b a red colored key - meaning it's a dead key. Double clicking it will allow you to change it from a dead key to an output key. When prompted for the output you can put in the same thing (by pressing Option-b).
Thus it will output the same character but will not be considered a dead key, so Intellij can bind it as a shortcut.
To enable your new layout you must save it into your ~/Library/Keyboard Layouts (it helps if you give it a new name with Keyboard -> Set Keyboard Name), and then enable it from System Preferences -> Language & Text.
Use Ctrl-Alt-<MNEMONIC>. IMHO much easier than having to install and configure a separate app.
I had the same issue on a new Macbook with VSCode which had worked fine on my old Macbook. When I typed alt-shift-f for format I got unicode instead. I realised the difference was my old Macbook had a British keyboard setup instead of the default "ABC - Extended". Adding the British keyboard fixed the issue for me.
I have a solution!
Place a file at: ~/Library/KeyBindings/DefaultKeyBinding.dict as:
/* ~/Library/KeyBindings/DefaultKeyBinding.dict */
{
/* Additional Emacs bindings */
"~f" = "moveWordForward:";
"~b" = "moveWordBackward:";
"~<" = "moveToBeginningOfDocument:";
"~>" = "moveToEndOfDocument:";
"~v" = "pageUp:";
"~d" = "deleteWordForward:";
"~^h" = "deleteWordBackward:";
"~\010" = "deleteWordBackward:"; /* Option-backspace */
"~\177" = "deleteWordBackward:"; /* Option-delete */
/* Escape should really be complete: */
"\033" = "complete:"; /* Escape */
}
It will hide the original textual input. But you can still get that by using Ctrl-Q before the combination.
So Ctrl-Q Alt-f gives me ƒ for example.
In fact, I'm writing this answer with the option keybindings enabled.
You can also add other keys you like! Official reference:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/EventOverview/TextDefaultsBindings/TextDefaultsBindings.html
Here is a good list of things you can bind to:
https://www.hcs.harvard.edu/~jrus/site/selectors.html
Oh, by the way, if you bind a key to an undefined action, your application will have a memory leak and your system will run out of memory in a few seconds. Tested on el capitan, in the hard way.
Using the Apple JRE, the Option key combinations will work as shortcuts instead of inserting special characters.
Download link:
https://support.apple.com/kb/DL1572?locale=en_US
It's an old outdated JRE (based on Java 6) but as of October 2015 it's still what seems to work best w/ my JetBrains RubyMine installation. (Anything else, the keys go back to inserting special characters.)
Use ABC as input method instead of ABC-Extended, then option + [char] would be able to use the application shortcut instead of showing special character.
I have found a decent workaround.
I use the software Karabiner to change my right enter key to control when held down.
So what iv done is remapped the option key to option+cmd+control, as I'm not aware of any commands that use all three modifiers. Now I can map the right shortcuts without any characters. But you could also map to additional keys if required
Add this to your private.xml: (in between root)
<item>
<name>Change option Key to cmd + control + option</name>
<identifier>private.optiontoelse</identifier>
<autogen>__KeyToKey__
KeyCode::OPTION_L,
KeyCode::OPTION_L, ModifierFlag::CONTROL_L | ModifierFlag::COMMAND_L</autogen>
<autogen>__KeyToKey__
KeyCode::OPTION_R,
KeyCode::OPTION_R, ModifierFlag::CONTROL_R | ModifierFlag::COMMAND_R</autogen>
</item>
Then reload the xml and enable the option at the top of the 'Change Key' tab
https://pqrs.org/osx/karabiner/

OSX Option/Alt as Meta: Is there a way to port or use emulate-mac-keyboard-mode in standard Emacs 24?

Emacs 24.1 was just released, and I once again feel inclined to use the "real" Emacs (Cocoa GUI version, from http://emacsformacosx.com) instead of Aquamacs. The only thing keeping me in Aquamacs is this:
In AquamacsEmacs, Option (Alt) is mapped to Meta - however, because
Option is used to input a lot of non-ASCII characters such as ü or £
on a variety of keyboards, the special character input methods take
precedence by default. You can deselect “Option key produces only
special characters” in the Options menu to use Option as Meta, or you
set the variable mac-command-modifier to ‘meta - you will lose
functionality, of course. If you use a non-English keybboard layout,
the emulation modes might be just what you want. While they leave the
Option key mapped to Meta, they will allow you to input many common
characters ([,],{,},\, etc.) directly with the Option key, just as you
would otherwise. You can find them in the Options → Option Key menu -
or use, e.g., M-x emulate-mac-german-keyboard-mode.
This question speaks about the same issue, and one of the answers is "use Aquamacs".
So in Aquamacs, I can use Option key as Meta and everything is fine, I can type e.g. [ with option(alt)-8 and still use alt as meta when I add this into my .emacs:
(setq emulate-mac-finnish-keyboard-mode t)
But is there any way to use this feature in Emacs 24? Has anyone ever tried porting emulate-mac-‌​keyboard-mode.el to standard Emacs?
And no, cmd as meta is not an option for me.
Has anyone ever tried porting emulate-mac-‌​keyboard-mode.el to
standard Emacs?
I haven't tested it, but this answer to the question you linked claims to have done just that.
I am not using Emacs but when I tried to remap certain keys for VIM I had some wired trouble. I finally found out that these issues were caused by Terminal.app as it somehow did not pass through some key events. I then switched to iTerm2 which also had some additional features, e.g. X11 mouse events without need for plugins.
I use EmacsForMacosx. This claims to be pure gnu emacs.
The options you are asking for are easily available through customize-group ns
(from what I know the naming comes from NextStep which kinda was a precessor of OSX)
personally I set the fn key to meta as I hardly use it within emacs. And keep alt as used by mac. You can also set left and right alternate to different functions - like for german on windows keyboards.

How do I get the behaviour of the 'Insert' key on VIM using a Macbook Pro without an insert key? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
Because the apple store couldn't help me, and indeed had never seen VIM before, despite the fact it comes installed as standard on OSX ;-).
With iTerm or iTerm2 you can map an unused key to insert. For example, I've mapped F19 to "send escape sequence" [2~ (that's the xterm escape sequence for the insert key).
In iTerm2, go to preferences, "Bookmarks", select the "Keyboard" tab, click the "+", press the key you want to map, select action "send escape sequence" and then enter [2~.
Surely you can just do a simple:
inoremap <C-l> <Insert>
I can't say I've ever had to use replace mode enough that <Esc>R wasn't quick enough for me.
You can use i instead of insert.
Taken from here:
Toggling insert mode
Press Ctrl-Space to start and to stop insert mode (the same suggestion using Shift-Space is above):
nnoremap i imap
Or you may prefer to map Ctrl-Space to a rather than i so that repeatedly pressing Ctrl-Space does not move the cursor back (remember that pressing I allows you to insert a character at the beginning of the line):
nnoremap a imap
You would put this in your .vimrc so it happens on start-up.
Either use Mac's onscreen keyboard or use a hotkey program to rebind one of your existing keys to Insert. One Superuser thread provides several Autohotkey equivalents for Mac such as Quicksilver.

Resources