I am trying to map my space key to make the Vim go into insert mode from normal mode.
The reason I want to do this is because sometimes I forget that I'm in normal mode and start typing as if I'm in insert mode. When I press the space key in between or even in the start of the page, it moves down and something or the other types due to the possibility of a press a
or i
in what I just typed.
So to avoid this I want to map my space key to insert mode from normal mode as we press i
to do so.
I tried the following:
map space :i
map <space> :i
But these doesnt seem to work.
You're mixing up the modes in your mappings; that's an important concept in Vim. Though there's a :startinsert
Ex command in Vim (where your mapping would indeed start with a :
), it's more straightforward to use the normal mode i
command:
:nnoremap <Space> i
You only want a normal mode mapping here, so :nmap
, not :map
; cp. :help map-modes
. And see :help key-notation
for why it's written <Space>
.
Finally: You should always use :noremap
; it makes the mapping immune to remapping and recursion.
strange requirement, but, you have your reason. :)
try this line out:
nnoremap <space> i
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With