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.
Related
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.
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.
Attempting to add a normal mode mapping in vim for Control + Enter to insert line break above cursor positon
:nmap <C-CR> O<Esc>
I am finding this does not work - what am I missing here?
This is probably based on your terminal rather than vim. You can tell what key your terminal sends by <C-Enter> via C-V C-Enter. Most likely this is a newline which you can use as <NL> in vim.
:nmap <NL> O<Esc>
Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today; though this particular mapping should work in GVIM, but not in most terminals. 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.
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.
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.
I have the below mapping in my .vimrc for mapping control key + 1, 2, 3.. for switching tabs. I am using gnome terminal in ubuntu 11.10, the control key mappings does not seem to work. could any one tell what I am doing wrong.
VIM - Vi IMproved version 7.3.154
map <C-S-]> gt
map <C-S-[> gT
map <C-1> 1gt
map <C-2> 2gt
map <C-3> 3gt
map <C-4> 4gt
map <C-5> 5gt
map <C-6> 6gt
map <C-7> 7gt
map <C-8> 8gt
map <C-9> 9gt
map <C-0> :tablast<CR>
syntax on
set shiftwidth=2
First ensure that your terminal emulator (Gnome Terminal) doesn't swallow the key combinations for its own functionality; by default Ctrl + number switches tabs. But I'm afraid you still won't be able to use all those combinations...
Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today. 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.
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.