inoremap <Tab> <Esc> and <C-I> <Tab> - vim

How it's use together?
inoremap <Tab> <Esc>
inoremap <C-I> <Tab>

Whatever you intend to do (your question is too terse), due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished. This also applies to <Tab> / <C-I>, <CR> / <C-M> / <Esc> / <C-[> etc. (Only exception is <BS> / <C-H>.) This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.
Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals, cp. http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8
But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim 8 major release.

Related

Map <C-i> and <Tab> independently

I know vim has a wickness related to the 7-bit ASCII encoding but the real bad thing is I can't map any of these chars with Vim + Mintty:
" ^ <C-'> <C-1> <C-2> <C-3> <C-4> <C-5> <C-6> <C-7> <C-8>
<C-9> <C-0> <C-i> <C-Tab> <C-S-Tab> ...
I also know that and are seens as the same char on vim but I found there is a workaround using the set keyword. For example I was able to map my <C-Tab> and <C-S-Tab> with this:
if s:is_cygwin
" <C-Tab> Next buffer
set <f26>=[1;5I
map <silent> <f26> :bn<cr>
imap <silent> <f26> <c-o>:bn<cr>
vmap <silent> <f26> <c-c>:bn<cr>
" <C-S-Tab> Previous buffer
set <f27>=[1;6I
map <silent> <f27> :bp<cr>
imap <silent> <f27> <c-o>:bp<cr>
vmap <silent> <f27> <c-c>:bp<cr>
endif
I am wondering if there is a way do something similart for <C-S-i> or <C-i>?
Perhaps there is a fork of vim that supports any keyboard mapping or some options for mintty that allow to tweak the chars encoding.
My current solution is very ugly. I use AHK (AutoHotKeys) to remap to another combination.
Does someone know any better workaround working on Windows/Mintty/Vim?
Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished. (Unless your terminal sends a distinct termcap code for it, which most don't.) In insert or command-line mode, try typing the key combination. If nothing happens / is inserted, you cannot use that key combination. This also applies to <Tab> / <C-I>, <CR> / <C-M> / <Esc> / <C-[> etc. (Only exception is <BS> / <C-H>.) This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.
Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals, cp. http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8
But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim 8 major release.

vim mapping of <c-i> in insert mode

I am facing problem with mapping a key <c-i> in insert mode. Once this command is executed in vim, my tab is also pointing to where <c-i> is mapped.
Mapping command executed:
:inoremap <c-i> <Up>
Now :imap gives:
i <Tab> * <Up>
I need quick help to debug this.
Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished. (Unless your terminal sends a distinct termcap code for it, which most don't.) In insert or command-line mode, try typing the key combination. If nothing happens / is inserted, you cannot use that key combination. This also applies to <Tab> / <C-I>, <CR> / <C-M> / <Esc> / <C-[> etc. (Only exception is <BS> / <C-H>.) This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.
Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals, cp. http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8
But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim 8 major release.

Vim -- Mapping of <c-<> not working?

I want to map c-< to be <c-w> <, so I put these in my .vimrc:
noremap <c-<> <c-w><
And it doesn't work.
:verbose map <c-<> shows:
<C-<> * <C-W><
Which means the mapping has succeeded.
If I try noremap <c-.> <c-w><, it doesn't work either; but if I try noremap <c-e> <c-w><, it actually works.
I don't understand.. does vim disallow kind of mapping>
You need to find different keys for your mapping - those won't work.
Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished. (Unless your terminal sends a distinct termcap code for it, which most don't.) In insert or command-line mode, try typing the key combination. If nothing happens / is inserted, you cannot use that key combination. This also applies to <Tab> / <C-I>, <CR> / <C-M> / <Esc> / <C-[> etc. (Only exception is <BS> / <C-H>.) This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.
Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals, cp. http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8
But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim 8 major release.

How do I map keys to assign a value in vim?

I am using highlighted search in vim. So when I search for a word, all occurrences of the word get highlighted. After I'm done, I want to remove the highlighting.
According to the Vim Documentation, :let #/="" clears the last searched pattern and removes the highlighting.
So I am trying to map Ctrl+/ to :let #/="".
I've added the following line to my .vimrc
nnoremap <C-/> :let #/=""<CR>
But it doesn't work. Ctrl+/ doesn't clear the search patter. On the other hand, if I manually type in :let #/="", it works fine.
What am I doing wrong?
I use this in my vimrc:
nnoremap <Esc> :noh<CR>
Mapping this to Esc seems natural to me.
Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished. (Unless your terminal sends a distinct termcap code for it, which most don't.) In insert or command-line mode, try typing the key combination. If nothing happens / is inserted, you cannot use that key combination. This also applies to <Tab> / <C-I>, <CR> / <C-M> / <Esc> / <C-[> etc. (Only exception is <BS> / <C-H>.) This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.
Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals, cp. http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8
But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim 8 major release.

map `ctrl +` to tabn

I am trying to map CTRL-+ to :tabn. But it does not work.
inoremap <C-+> :tabn<CR>
inoremap <C--> :tabp<CR>
nnoremap <C-+> :tabn<CR>
nnoremap <C--> :tabp<CR>
It does not work in insert mode also not in normal mode.
If I try the following (without CTRL), then it works, but then I can't switch tabs when I am in insert mode:
nnoremap + :tabn<CR>
nnoremap - :tabp<CR>
How can I map CTRL-+ to :tabn so I can switch tabs when in insert mode?
Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished. (Unless your terminal sends a distinct termcap code for it, which most don't.) In insert or command-line mode, try typing the key combination. If nothing happens / is inserted, you cannot use that key combination. This also applies to <Tab> / <C-I>, <CR> / <C-M> / <Esc> / <C-[> etc. (Only exception is <BS> / <C-H>.) This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.
For me (in English Windows GVIM), it is possible to map Ctrl + - as <C-_>, though.
Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals
But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim 8 major release.
Only a few control-printable key chords can be detected (and therefore mapped) by Vim, and these are listed in the FAQ. Unfortunately <CTRL-+> and <CTRL--> are not mentioned in this list, so it looks like such mappings are impossible.
There is on-going discussion about whether to redesign Vim's key model, but this probably have to wait until Vim 8.0. I am not optimistic.

Resources