Vimperator: <C-v> is not passing through the key - keymapping

is supposed to let keys pass though so that the consequent key press is recognized as if vimperator is not installed. I am getting a behavior that is equivalent to p of vimperator key, where the contents of the clipbaord is entered into the omnibar (or search bar). This seems like the default behavior as I have no mapping to and there is no mention in the help page. How can I bring the pass through key back?

try hitting 'i' or 'Insert' (ignore-keys feature).

Related

Translucent Vim map for short manual about keys after it

In (Neo)Vim, I want to configure a key as if it passed through one-way mirror.
For example, in normal mode, when I type <Leader>, the command :echo "w: Separate Window f: Open File c: Configure Settings" run (so I can get help from at the bottom of the screen), but the <Leader> still has influence on following keys --- such as w, f, c, and so on --- and <Leader><KEY> works properly.
I mapped lots keys with <Leader>, so it will be very helpful for me to display a short manual about keys follow <Leader> at the bottom of the screen when I type <Leader>.
Thanks.
First, <leader> is not a special key at all. It's a placeholder expanded by Vim to the current value of mapleader whenever it is used. Assuming your mapleader is , (as instructed in :help mapleader), the mapping below:
nnoremap <leader>f :find *
will be registered as:
nnoremap ,f :find *
Second, when Vim detects that the key you just pressed is part of several custom or built-in commands it waits a bit for you to press more keys in order to decide what to do. With , as your mapleader, pressing , will always puzzle Vim because , is an actual command in its own right and you have a bunch of custom mappings starting with ,. In this situation, Vim waits for a full second before deciding you actually wanted , and not ,f.
Third, you would almost certainly need to write a completely separate mapping mechanism for achieving you idea. A mechanism that would:
listen to key presses,
trigger a specific function when you press <leader>,
that prints something helpful in the command-line,
and waits indefinitely for another key to be pressed.
This doesn't sound trivial at all. Did you take a look at the "scripts" section of http://www.vim.org?
Four, the whole point of a mapping is to map a common action to an easy to remember shortcut. You definitely have too many mappings if you can't remember all of them. Maybe it's time to reconsider the root issue instead of looking for a workaround?
You can do that with the following mapping:
:nnoremap <Leader> :echo "w: Separate Window f: Open File c: Configure Settings"<Bar>call feedkeys((exists('g:mapleader') ? g:mapleader : '\'), 't')<CR>
This uses feedkeys() to send the <Leader> again after the help has been shown. However, this solution has the key timeout downsides already mentioned by #romainl: The message will only appear after the 'timeoutlen' delay, and then you have to press the correct mapping key within 'timeoutlen'.
alternative
I would rather print the help on <Leader><Leader>. There are no timeout issues here. If you have pressed <Leader> and then fail to remember what's the next key, just press <Leader> again, read the help, and then start again with the (now memorized) full mapping!

Remap left command key to leader in VIM?

I have hand pain in my right hand. I was hoping there was a way to map leader to the left command key. From what I've read this is not possible but perhaps there's a new plugin I'm not finding?
If it's not possible to map to left command key, is it possible just to map to the command key? I tried let mapleader="<D>" and let mapleader="\<D>" and this does not work.
Also, is there a way in Vim to remove binding such as command+n (new window) and reassign that to something else?
The map Leader is designed to define a two key mapping. In other words pressing one key and then the other within a timeout. For example if leader were a then a map of <Leader>b would mean depressing a then depressing b in quick succession.
The command key (and also meta, control, and shift) are all modifier keys and therefore do not register to the computer as a normal key press. You would have to attach an actual key value to to a modifier for vim (or the system) to recognize that a key sequence was entered. The closet you could get would be to have a modified key for the leader like :set mapleader=<D-a> would produce a key sequence like <D-a>b which seems more complex then simply ab.
So no, there is no way for the leader setting to remove the two step mapping in lieu of a single step modified key.
According to :help cmd-key of you want to reassign a command based mapping you first have to unbind it then reassign it. The help docs do much better at describing that then I could here.
I found a really good hack but it requires terminal vim. If you use Iterm2 as I am, you can go into the preferences and map the left option key to do "Meta", now in vim just map it using let mapleader="\<M>
I included a screenshot of the preferences tab in Iterm 2 for easy reference. Hope this helps someone.

how to remap <C-;>

I want to use the following code to quickly go from insert mode -> command mode. The problem is it just doesnt seem to be registering my keys. I've tried with control (nothing happens) and i've also tried with command (D) and it just says spellcheck not activated.
" Quick command mode from insert
imap <C-;> <esc>:
How do i go about doing this? is there an easier vim way that I'm not aware of?
Certain Ctrl chords can't be mapped, including Ctrl-;.
This is mentioned in this FAQ, see also the Vim FAQ:
20.4. I am not able to create a mapping for the <xxx> key. What is wrong?
First make sure that the key is passed to Vim. In insert mode, press Ctrl-V
followed by the desired key. You should see the keycode corresponding to
the key. If you do see the keycode, then you can create a mapping for the
key using the following command:
:map <C-V><xxx> <your_command_to_be_mapped>
For more information, read
:help map-keys-fails
:help :map-special-keys
:help key-codes
The tip about trying to print the character using Ctrl-V is good to remember if you run into this problem with another key combo.
I tried it, however it doesn't seem to work, also as pb2q said, it just can't be mapped. But there are other ways to escape using a Ctrl key combination.
For example, you can also escape insert mode with the following key presses:
Ctrl-[
Ctrl-c
On OS X (I think Lion and above), you are able to map alt - ; using this method, alt - ; on OS X outputs รง, which you can map.
But at a MacBook, I prefer to use PCKeyboardHack to map caps lock to esc. Or at Windows, use a tool I've created myself for that or even Ctrl2Cap.
EDIT
oh sorry, I thought you wanted to switch to normal mode, that's why I talked about caps lock mappings.

Is it possible to map <C-;> to : in vim?

I use capslock as control so it is more natural to use as : but noremap <C-;> : does not work. Is it possible to do such mapping in vim?
From Vim FAQ (also available through this nice plugin):
20.4. I am not able to create a mapping for the <xxx> key. What is wrong?
1) First make sure, the key is passed correctly to Vim. To determine if
this is the case, put Vim in Insert mode and then hit Ctrl-V (or
Ctrl-Q if your Ctrl-V is remapped to the paste operation (e.g. on
Windows if you are using the mswin.vim script file) followed by your
key.
If nothing appears in the buffer (and assuming that you have
'showcmd' on, ^V remains displayed near the bottom right of the Vim
screen), then Vim doesn't get your key correctly and there is nothing
to be done, other than selecting a different key for your mapping or
using GVim, which should recognise the key correctly.
Trying the above with <C-;> shows that it is not captured by vim/gvim...

mapping for // behaves weird for regular search with paste

I have a mapping to use // as a global git search in the project for word under the cursor:
nmap // :let #/="...
The problem is that after I added this mapping regular search behaves weird when I try to paste the search term. i.e. if I hit / and then Paste (Apple-v on Mac) I get the following instead:
/<t_<fa>X>
Update.
It really doesn't matter what is the exact mapping. for example, just try the following:
map // echo "test"<cr>
now type // and you will see test in the statusbar.
now type / and immediately hit paste. I get
/<t_<fa>X>
I have the same behavior to. It seems to be a bug in MacVim as this doesn't occur in MacVim in terminal mode.
The mapping (which key and what) doesn't seems to change anything. It seems that every time your press while Vim is waiting for a key to complete a mapping, rather cancelling the mapping and doing what should do, it cancel it but send this key.
The problem doesn't occur if you wait until mapping timeout.
You can reproducet it in insert mode like this
:imap vv vv
the type v and fast enough in insert mode and you'll have the same X>.

Resources