how do I use the # key in vi? [closed]

How can I make a number sign show up???


Solution 1:

Assuming a US keyboard, Press i to go into insert mode, and then shift-3. You can use either shift key, and press it the same time as the '3' key. The three key is after two, and before four.

Solution 2:

looking to this http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.htmlalt text
(source: viemu.com)

Solution 3:

There is the very remote possibility that the user is using an antique unix that has # mapped to delete and @ mapped to kill (^U on most traditional modern systems).

If his system is configured this way, he will not be able to type a # because every time he does it will delete whatever character is to the left of where he is trying to type the #. The simplest way to fix this is stty erase (ctrl-V)(backspace key).

This is unlikely to be the case -- it's not likely that anyone is running irix 5.4 or hp/ux 10.20 these days, but who knows, right?

Solution 4:

,If you're using a colour scheme and working in a file format that denotes comments as lines starting with "#", make sure that it's not erroneously setting comment highlighting to the same colour as that of the background. I ran into that problem myself and was pulling my hair out.

Solution 5:

For anyone who might still have this problem, I had the same thing. It was a problem with:

  • UK Mac configuration for # is alt + 3
  • Configuration of the terminal, not vim, to use alt as meta key or esc+ key

For fixing this in iTerm2, left alt key is set to Esc+ by default, change this to Normal. Presumably there will be something similar for other terms.