How to insert the hash symbol in TextMate for Mac on a British Keyboard? - macos

When using TextMate on a Mac for HTML (and indeed any other language) I can't enter the hash (#) symbol using the keyboard. British keyboards have a £ symbol on the 3 key which displaces the hash symbol.
In several other Mac application, you can press alt+3 to get the hash symbol, but in TextMate, that doesn't work.
Is there an alternative that more experienced Mac programmers than me know of?

For programming it's generally a good idea to switch to a US keyboard layout - this only really affects the use of Shift + 3 vs Option + 3 (£ and # get toggled - you can still get £ via Option + 3).
System Preferences -> Language & Text -> Input Sources -> U.S. (and check "Show Input menu in menu bar" for convenient toggling between US and UK keyboard layouts).

Doesn't Alt-3 work for you?
I just checked it on my MBP and it works fine. (I had to first enable/activate another keyboard by: system preference > Language & Text > Input Sources > (the check the boxes next the languages you want to enable. Close Sys Pref, then click on flag in upper right hand corner of your menubar. Then click on either "Show Keyboard Viewer" or "Show Character Viewer"--either will show you this key binding.
My bust--Paul's answer wasn't in when i first looked at this Q; only noticed it after i fired off my (obviously redundant) answer.

Related

Xcode comment selection shortcut not working on European keyboard

I have an Apple keyboard (Norwegian) with numeric keypad and I can't get the Xcode shortcut for comment selection (cmd + /) to work. I have to change to Input source = US every time I want to comment out a block. When I change from US to Norwegian input source the Xcode -> Editor -> Structure -> comment selection shortcut disappears.
Does anyone know why changing input source from Norwegian/Swedish/German (I guess all European languages) have this effect. What is the "European" shortcut for comment selection ?
Are Europeans not allowed by Apple to comment select..!? ;-)
Any ideas would be much appreciated !

Issue switching language input

On windows 7 new install I couldn't change language via right alt +
shift.
I could do by the left alt + shift.
I used to change by right alt shift and left alt shift all worked in the previous win7 installation.
Is there anyway to solve this?
Is the keyboard layout set correctly and is the right Alt in fact an Alt-Gr instead of a plain Alt key?
If you right-click your taskbar I think there may be an option to open your Keyboard and Language options. If I'm not remembering correctly then you can certainly get to it through your Control Panel. You can change the keyboard layout here.
Open a text editor and try typing in the alternate and lesser used keys such as #$/|~` and so on to test if the right keys produce the right characters.
The on screen keyboard can also give you a display of what layout the computer thinks you are using. You can find that in your Accessibility Options.

Is there a way to make alt-f and alt-b jump word forward and backward instead of printing ƒ and ∫ on Mac?

I understand that Mac has some Emacs keybindings enabled by default (e.g. Ctrl+A move to beginning of line etc.). If I open TextEdit for example I can navigate like in Emacs.
But when I try Alt+F or Alt+b for move to next word or last word it does not work. It prints out ƒ and ∫ instead.
Is there a way to jump words instead?
I think that I did not tinker with the keybindings and I use the US layout on a german keyboard.
If you want to re-enable them for the terminal
Terminal -> Preferences -> Keyboard
Check 'Use Option as Meta key'
my iTerm2 version is 3.1.6, profile -> keys -> set Esc+
Maybe one of these helps? (I don't use OSX myself, so I can't test anything).
http://blog.sensible.io/2012/10/19/mac-os-x-emacs-style-keybindings-everywhere.html
http://aufflick.com/blog/2006/01/10/emacs-keybindings-everywhere
Summary from first URL:
Create file ~/Library/Keybindings/DefaultKeyBinding.dict with the following content and restart all apps.
{
"~d" = "deleteWordForward:";
"^w" = "deleteWordBackward:";
"~f" = "moveWordForward:";
"~b" = "moveWordBackward:";
}
I'm a little confused if you're talking about the keys (within different apps on OS X) or specifically Emacs. On OS X the standard keys you would use to jump between words is:
option/alt + Left Arrow or Right Arrow
If it's specific to Emacs for OS X:
For Terminal.app, starting from Snow Leopard: Go to Preferences > Settings > Keyboard > Use option as meta key.
For iTerm: Go to Manage Profiles > Keyboard profiles > (your profile) > Option Key as…
If you want to use Option key for both international characters and
Meta key in Emacs, see info below for iTerm 0.10.x patch and/or binary.
Alt-b and Alt-f for navigating by word also works for your shell now.
UPDATE: The link the original website providing the patch is no longer online, however I was able to retrieve the cached information from the archive.org:
OSX + terminal + Meta key + national characters
Quite a mix, right? If you’re user of one of those keyboard layouts that have hidden some non-ISO1 characters under Option-key shortcuts and you use command line – read on, I might have a treat for you.
As it stands today, if you’re OSX user, and would like to use your Option (Alt) keys for both national characters and Meta-* shortcuts, you’re in for an unpleasant surprise – you can’t. It’s one or the other: both iTerm and Terminal.app allow you to flip between Option keys role, but neither of them allows you to use Option for both. Under Linux, it’s customary to use left Alt for Meta-* and right Alt for any national characters you might require. Same goes for Windows. Of course you can just train yourself in using ESC key in a prefix manner, but that’s avoiding the real problem.
Getting annoyed by this state of things, and faced with some Emacs usage, I decided to take advantage of the fact that iTerm is opensource software, and see if I can make a tiny change, to cater for my needs. Surely enough, after ~25 minutes I got a trivial patch: just changed the mask that iTerm uses for detecting that Option key is pressed down. It took few hours and 5 chapters of Cocoa book, to turn that into fully-fledged option in Keyboard Profiles section of iTerm. This was my first foray into lands of Objective C; while I came back victorious, I don’t see myself writing anything bigger in Objective C in nearest future.
Here’s the meat: ( https://sourceforge.net/p/iterm/patches/44/ )
“right Option is Normal” patch;
full patch allows you to pick which keys should be treated as Meta (both, only left, only right);
The patches were made against 0.10.x branch, at revision
1871.
Once you have the binary, launch it and go to Bookmarks > Manage profiles > Keyboard profiles. If you select a keyboard profile, you should see a new dropdown at the bottom of the keybindings list.
The options should be pretty much self-explanatory. The configuration shown above is the one I’m using — this way I get all Meta-* shortcuts with my left Option key, and all Polish characters with right Option key. Which is the way it Should Be™ :)
I haven’t heard from iTerm authors yet, so I have no idea whether this patch is going to merged upstream or not. I’ve been using my patched version for almost week and a half now, and nothing major exploded. Yes, iTerm is slower to redraw the screen on larger terminals (say, 130×80), but there are certain features (like 256 colors support) that make up for that.
more info: http://www.emacswiki.org/emacs/EmacsForMacOS
On iTerm2 3.0.15, go to:
Preferences -> Default -> Keys tab ->"Left option() key acts as:"
and change the value to:
+Esc
Solved this at the OS level as follows,
⟶ System preferences
⟶ Keyboard
⟶ Input Sources Tab
⟶ + at bottom left
⟶ Others in the left panel
⟶ add and select Unicode Hex Input from right panel
 ✓  Mac no longer prints anything on alt+letter|number
 ✓  enter unicode characters via alt+[code]
 ✅ the OS does not grab alt key shortcuts!
You should use KeyRemap4MacBook. In the Emacs Mode section, you will find numerous options to use the Option key as Meta including Option+BF to Option+Left/Right.
However, if you're a hardcore Dvorak user like myself who wants to use key bindings such as M-b and M-f using the original Dvorak layout, there's a problem. You can only "move backward/forward one word" in QWERTY layout. I use version 8.4.0 so I don't know about the latest version for Mavericks.
I use BetterTouchTool. Works like this:
Basically remaps Option-F and Option-B to Option-Right and Option Left, and I turned this on for any apps that I want the shortcut in, e.g., Firefox, Obsidian, Slack. Works great!
For Hyper you can fix the option key by setting the following configuration to your ~/.hyper.js file:
module.exports = {
config: {
modifierKeys: { altIsMeta: true }
}
}
source

How can I put 0x08 ascii character using MacBook?

I'm writing this question because one little invisible problem has taken from me hours and hours of dummy searchings, and the time just has been wasted (here is that question: CSS: Is there any difference between these two parts?)
Does anybody know how the character 0x08 ("backspace" in ASCII) can be written into a text using a MacBook and a simple IDE (I use the "Coda")?
There is no ability to press Alt + 08 on MacBook (there is no digital keys part on the MacBook's keyboard).
How it can happen?
Did you copy & paste it from anywhere? Because the only way I know - apart from what SCFrench suggested - is to enable this in Terminal by typing:
stty erase SPACE CTRL+V CTRL+H RETURN
Not sure if this is the easiest way, but:
In the Keyboard system preferences panel, check "Show Keyboard & Character Viewer in menu bar".
Find the Keyboard menu bar icon (on the right side of the menu bar), click it, and select "Show Character Viewer".
In the Characters window that appears, find the "View" pop up menu and select "Code Tables".
Select the Unicode coding tab.
In the middle section where all the characters are displayed, click on the entry for 0008 (it will be blank, but the Name: field will say "BACKSPACE").
Click the Insert button in the same window.
Since the character is non-printable, it doesn't actually show anything in the text editor, but (at least in TextEdit) you will see that you have to hit the left or right arrow key more than once to move past it. I also confirmed by dumping the file in hex that it contains a 08 byte.
You could also use this technique to set up a Text Substitution in the Text tab of the Language & Text system preference panel.
Shift + Up Arrow + Delete/Backspace. It's a bug.
http://www.openradar.me/5288750

Meta and # in a UK mac terminal

In the mac terminal application there is a setting (preferences -> keyboard) that lets you set "use option as meta key". This is useful as a lot of unix boxes use bash as default shell and that has emacs keybindings M-f and M-b that let you skip words.
Problem is that on a Mac with a UK keyboard the # symbol is tricky to get to - normally it can be typed with alt-3, but not if you are in a terminal and alt=meta.
Anyone have a nice way round this?
I am using zsh and the following saved my day:
bindkey -s '^[3' \#
Set your keyboard language ( System Preferences->International->InputMenu ) to Australian
It is the same as UK except shift-3 gives #. You do lose the pound sign but if I do currency I use the ISO three character code GBP
The Australian layout is identical as mentioned except # is mapped to Shift 3 and £ is mapped to Alt 3.
Swap to Aus and the swap your ALT behaviour. This has annoyed me for while especially as it is in a non UK position to start with.
Earlier today I stumbled on a great solution to this on Graeme Sutherland's blog so thought I'd summarise it here in case it disappears.
If you want to stick with the built-in Terminal and don't want to lose the £ sign, you can use Ukelele roll your own keyboard layout to switch the section (§) key for hash instead. Quite a handy location for typing '#!' too :)
The keymap file Graeme created is here, but if you want to make your own you can simply take the British one as a base it's pretty straightforward to create the new keymap file.
Copy your new keymap file to ~/Library/Keyboard Layouts
Go to System Preferences - Language & Text - Input Sources
Scroll down to 'British with # for §' (or whatever you put as its name in Ukelele) and check the box
Check 'Show Input menu in menu bar'
Click on the flag in your menu bar at the top of the screen and choose your new input source
This input source can then be used in all apps, or just the ones you want it for.
I appreciate this and the linked question are quite old but thought this might help someone else.
ESC is another meta shortcut :). You don't have to keep pressing it though.
So in your situation, you might just need to press ESC once, and then press alt-3.
See image to get the details as to how to setup a shortcut in your terminal and fly free
I'm using iTerm2 and I was having this problem. With iTerm2 you can use the left alt key as a meta key, and the right as a normal key. So ralt-3 does the # key.
Based on ericteubert answer for zsh for bash you bind the key, I've added this to my .bash_profile:
bind '"\e3":"#"'
For vim you can add the following to your .vimrc
inoremap <ESC>3 #

Resources