Use of hash (#) on OS X with UK MacBook Pro

I have MacVim on a UK MacBook Pro. I can use the hash on TextMate by typing alt 3 but in vim this does not work. Do you know how I can type a hash using VIM on a UK MacBook Pro?

The problem is happening in any VI/VIM with a Mac with UK keyboard. If I am in insert mode, I type alt + 3 (hash char in a MacBook Pro UK keyboard) VI exists to insert mode.


Solution 1:

If you're using iTerm2 then the left option acts as +Esc by default.

To fix this you can:

  • Go into Preferences -> Profiles -> Default (or your profile) -> Keys
  • In there you should see a section at the bottom called "Keyboard Behavior" and "Left option key acts as:"
  • Select the 'Normal' radio button and you should find you can type the hash symbol.

screenshot of iTerm2 preferences

Solution 2:

Open Terminal preferences. Select the current Profile and Keyboard. Disable the Use Option as Meta key preference shown here: enter image description here