How can I make a number sign show up???
7 Answers
looking to this http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html
(source: viemu.com)
- 1,213
- 3
- 15
- 22
- 3,329
- 21
- 29
-
Wow, thanks for that cheat sheet. Also love their 7 lesson sheets with a subset of the cheat sheet for specific functions (e.g. searching) – Harm Apr 12 '22 at 08:08
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.
- 82,107
- 71
- 302
- 444
-
I am teasing a bit of course, are you just trying to edit a file? vi has to modes, command and input, press i to go into input mode, and esc to go back to command mode – Kyle Brandt Aug 25 '09 at 17:55
-
Also, you might try a command like 'nano' for the time being to edit the file if it is installed. – Kyle Brandt Aug 25 '09 at 17:57
-
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?
- 11,784
- 6
- 41
- 51
-
and often users don't notice this because their system is using an old version of bash that ignores these stty settings; they won't notice their wacky stty settings until they run an app that doesn't override the settings (such as vi). – chris Aug 25 '09 at 18:51
-
plus 1 for stirring up (useful) memories from the good ol' days... – Jessica McKinnon Sep 08 '09 at 19:08
,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.
- 145
- 1
- 8
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.
- 11
- 1
-
Thanks Doug - easy to miss! Useful advice for British keyboard users and iTerm – James Murphy May 29 '19 at 10:15
If you're in insert mode, it should be just the same as any other application. If it doesn't say "--INSERT--" at the bottom of the terminal, hit i, then try typing. When you're done, hit escape to get out of insert mode and back to "command mode".
On the off chance you're using a Mac with a UK keyboard layout, you need to use alt+3 to get a # symbol.
- 134
- 4
-
1Sorry, I should have added.. the "--INSERT--" thing will only show up in vim, which substitutes vi on a lot of systems. The only way to know you're in insert mode in actual vi is if you can, well, insert stuff. – Andrew Aug 25 '09 at 18:10
Assuming a UK keyboard layout, it can be a pain to input #
(the hash symbol), due to various factors (meta key, Hash on Alt+3, etc).
You can remap any other key, e.g. £
, to #
in your ~/.vimrc
file:
noremap £ :norm i#<CR>
Now, when you press Shift+3, it will input #
at current cursor position.
- 101
- 2