VIM Keybindings: what key does <C-C> correspond to? - vim

i am trying to figure out vim key bindings... what key does correspond to? or more generally how do I read vim key bindings? I looked at the VIM documentation but it was not very clear.

It's Ctrl+C. See :help key-notation.

You can use #romainl's answer:help key-notation to find the notation of each modifier keys.
And you can use below commands to see the current mappings in your vim:
:nmap Show key maps for normal mode
:vmap Show key maps for visual mode
:imap Show key maps for insert mode
:map Show all the key maps

Related

vim: Tagbar windows opened when typing <Enter> in normal mode

When typing <Enter> in normal mode in Vim with the Tagbar plugin installed, the Tagbar window is opened automatically. I want to disable this functionality. What must I do?
put the flowing code in you .vimrc
unmap <cr>
Your mapping for <C-m> is actually the cause of the Enter key opening Tagbar. If you remove that map from your vimrc, the enter key will no longer trigger :TagbarToggle.
Mappings for <C-m> and <CR> (Enter) are synonymous in Vim:
The following table shows the mapping between some of the keys on the keyboard and the equivalent Ctrl-key combination:
Ctrl-I Tab
Ctrl-[ Esc
Ctrl-M Enter
Ctrl-H Backspace
If you use one of the Ctrl-key combination in the above table in a map, the map also applies to the corresponding key. Both the keys produce the same key scan code. For example, if you create a map for CTRL-I, then you can invoke the map by pressing Ctrl-I or the Tab key.
This means when you set nmap <C-m> :TagbarToggle<CR>, it is the same as
also setting nmap <CR> :TagbarToggle<CR>.
You'll probably want to choose a new key instead of M. The alternative is to
change the key code sent by <C-m> at the operating system level with some
remapping program.
The terminal key bindings come from readline, the program that processes input text in
your terminal prompt. A full list of key bindings is in the readline
manual.
You can find more info about Vim key codes by typing :help keycodes in Vim, or reading the help docs here.
Try :help tagbar to open the documentation. It sounds like you might have a mapping in your vimrc file that says something like
nnoremap <silent> <CR> :TagbarToggle<CR>
or
nnoremap <silent> <CR> :TagbarOpen<CR>
if you find and remove that mapping will no longer open Tagbar

Can some share how to write vim map

new to vim, recently came across mapping keyboards issues, what get on google and stackoverflow is only something like this map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR> and map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>, then I searched Vim documentation: map http://vimdoc.sourceforge.net/htmldoc/intro.html#<>, but what it also does not explains the syntax, the meanning of the symbols, can someone suggest some reference materials for this? Thanks very much!
A mapping like the ones you mentioned has three parts:
the type of mapping (map/nmap/imap/vmap/... and the corresponding noremap versions). This determines in what modes the mapping is active. map means normal mode, visual mode and operator-pending mode. When using noremap/nnoremap/... the mapping is made with respect to Vims standard keybindings, otherwise the mappings can themselves call mappings.
The key(s) to bind. This can be a normal key, a control character like <C-\>, or a sequence of keys.
a key sequence to map to.
In your first case, you map the key <C-\> (control-backspace) to :tab split<CR>:exec("tag ".expand("<cword>"))<CR> in normal, visual, and operator-pending mode.

Vim pymode: meaning of <C-c> key combination

I have come across the following key combinations(...i assume) in vim pymode documentation. <C-c>, <C-C>, <C-X><C-O>, <C-P>/<C-N>. How are they to be interpreted?
<C-c> and <C-C> both mean Ctrl+C.
I'm sure you can infer how to type the others.
See :help key-notation.

vim shortcuts - how do i know if there exists already a shortcut

I'm a vim newby and i try to make my own custom shortcuts...
But I have following question:
How do I know if I'm remapping a built in shortcut?
Do I have to know all shortcuts before I know if I overwrite something?
If you want to map something, you could always check has been it mapped to something already or not by
:verbose map {your mapping here}
You can display them with the :map command. Read :help map & here for more info.
:map
Other variants are:
:nmap - normal mode mappings
:vmap - visual mode mappings
:imap - insert mode mappings

How to scroll in insert mode?

Is there a default key for scrolling in insert mode? I know that I could just
:imap <F5> <ESC><C-e>a
:imap <F6> <ESC><C-y>a
but I'm wondering if there's any key binding there by default.
For completeness, there are two dedicated commands for scrolling in insert mode, CTRLXCTRLE and CTRLXCTRLY. They are probably the proper ones to map.
See the documentation here: :h i_CTRL-X_CTRL-E.
In normal mode CTRLE and CTRLY do the same thing, I use them quite often.
In insert mode, type Ctrl-o, then type zz.
It'll set current line in the middle of the screen.
Actually, you can type any command.

Resources