Harshit Jariwala
Harshit Jariwala

Reputation: 31

mapping of control and shift key not working in vim

I tried to map Ctrl and Shift key with spacebar in VIM (not GVIM) normal mode, but seems to be not working for me , Here are my mappings :

nmap <C-Space> :nohlsearch<CR>
nmap <S-Space> :w<CR>

Other keys got mapped in normal mode & getting expected results but Ctrl & Shift doesn't mapping with other keys. Could anyone know this reason ? .

Thanks.

Upvotes: 3

Views: 2461

Answers (1)

Thomas Dickey
Thomas Dickey

Reputation: 54583

Control (Ctrl) and Shift are modifier keys. Unless you have radically changed your keyboard configuration, those keys do nothing unless you press at the same time a non-modifier key. Likewise, pressing two modifiers at the same time without a non-modifier key does nothing.

That said, most of the keys on a terminal can be modified. Due to the way things evolved back in the 1970s / 1980s, not all of the modified keys differ. For instance, it is common to have both of these sending an ASCII NUL (0):

control space
control @

That is because originally the control key acted to suppress all but the low-order 5 bits of an 8-bit character. Space is 32, and @ is 64 in ASCII.

Further reading:

Upvotes: 1

Related Questions