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.
Related
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.
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.
Say I want <C-*> to provide me the functionality of the:set nohlsearch command. How do I accomplish this? The map command only seems to be able to map a set of keystrokes with another set. How can a key combination be mapped to a command?
You'd do it like this:
:nnoremap <C-*> :set nohlsearch<CR>
<C-*> means pressing Ctrl and Shift and 8 (on an English keyboard layout, at least) simultaneously. Unfortunately, that particular combination 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.
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.
What you can do is choose another key combination, e.g. one of the function keys:
:nnoremap <F5> :set nohlsearch<CR>
As others have already pointed out, all types of keybindings are not possible due to the way the strokes are sent to the terminal. However, to accomplish what you are asking for (:nohlsearch) this code below allows you to toggle the highlighting by pressing space.
set nocompatible
let g:highlighting = 0
function! Highlighting()
if g:highlighting == 1 && #/ =~ '^\\<'.expand('<cword>').'\\>$'
let g:highlighting = 0
return ":silent nohlsearch\<CR>"
endif
let #/ = '\<'.expand('<cword>').'\>'
let g:highlighting = 1
return ":silent set hlsearch\<CR>"
endfunction
nnoremap <silent> <expr> <Space> Highlighting()
You should be able to do so in your .vimrc :
nnoremap <C-*> :set nohlsearch<CR>
though I am not sure is always a supported shortcut.
See another exemple here
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.
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.