Vimperator copy/pasting

I'm trying out Vimperator. I mainly wanted it for the hjkl scrolling, and I like its "hint" system for following links. These two features are really all I need; I think.

I don't mind the other features, it just sometimes get in my way.

The thing that annoys me the most is copy/pasting. I'm used to Ctrl + c/Ctrl+v, I don't mind using another shortcut, but ..

:help yank indicates that copying selected text is done with Y, but the only method mentioned for pasting is the middle mouse button!

This is so ridiculously against the spirit of Vim!

How can I paste in Vimperator without using the mouse?


Solution 1:

The best and easiest thing that you can do is to remap the keys. It's not hard. Put this into your _vimperatorrc (or .vimperatorrc in Linux)

noremap <C-c> <C-v><C-c>
noremap <C-v> <C-v><C-v>

<C-v> is by default mapped to "Pass next" mode, which means that next key you press is sent directly to Firefox, without being processed and eaten by vimperator. So the mappings above just activate the "Pass next" mode and send the respective shortcut.

There is even a vimperator plugin which extends this even further and remaps all common windows shortcuts, so they behave as expected.

Solution 2:

I'm surprised there wasn't a more accurate answer given to this question. The chosen answer's plugin link solved the OP's issue, but no one actually explained how to paste something into a text field without using the passthrough (C-v) mode.

If you are in a text field in INSERT mode and would like to paste something, the obvious thing to do in vi-land is to press ESC and p to paste. In vimperator, this doesn't work- ESC takes you out of INSERT mode completely and into the mode in which you work with the page/tab as a whole.

Vimperator solves this by having an additional BASIC mode- TEXTAREA. When in mode TEXTAREA, you can use the supported commands you'd use in vi.

Enter TEXTAREA mode: C-t
Paste:    p
Copy line:    yy
Delete Char:  x
Delete Line:  dd

Etc.

This doesn't appear to be well documented- I ended up figuring it mostly by mistake. It works the same in multiline and single line textboxes.

Solution 3:

Right now, vimperator remaps both Ctrl+C (from 'copy' to 'cancel') and Ctrl+V (from 'paste' to 'pass-through'). On Linux, the preferred method of copy/paste is with the middle mouse button, so this is not a problem. On Windows, this is a user-interface disaster and it badly needs to be fixed.

There are three places you might copy from: text from a Web page, text from a form field, and text from an external application. There are two places you might copy to: into a form field, and into an external application. The address and command bars work like form fields.

Copying from...
     A web page: 'Y' works, '^C' doesn't
     Form field: 'Y' doesn't work, '^C' does
     Extern application: 'Y' doesn't work, '^C' does
  Copying to...
     Form field: '^V' doesn't work, '^V,^V' does
     External application: '^V' works, '^V,^V' pastes twice
 Or, seen another way
       Copy  Paste
 Page  Y     N/A
 Form  ^C    ^V,^V
 App   ^C    ^V

Ordinary users won't memorize that table. They'll never figure it out, because it's not documented explicitly, and they wouldn't read it even if it was. Instead, they'll use the right-click menu, the only thing that works everywhere. In fact, a few weeks after I started using Vimperator, I caught myself doing just that, in a completely unrelated application, something I had never done before.

We need to restore ^C and ^V to their original, rightful functions as copy and paste, which means displacing the ^C=cancel and ^V=pass-through hotkeys. In fact, both of these hotkeys are unique to vimperator and do not appear in vim. ^V means 'block visual' in vim, which doesn't apply in vimperator, so pass-through can be easily assigned to some other key. I suggest backslash in command mode and ctrl+backslash in both command and insert modes. That leaves ^C. I think that should be moved to ^S. This has two good mnemonics: it's 'stop', and it's also the Unix hotkey for XOFF, which is useless but semantically similar. ^S is currently "save page as" in vimperator, which is rarely used and can still be accessed with :save or :saveas.

Undo is also broken; it was ^Z, but ^Z is not pass-through mode and there's no way to undo edits in a form field without using the mouse. I see no reason not to move that to another hotkey, especially since ^Z in vim means suspend, which is completely unrelated, and unexpectedly finding yourself in pass-through mode is extremely disorienting. I can't think of a non-arbitrary hotkey to change this to, but ^Z was pretty arbitrary in the first place, so any unused hotkey will do.

Soruce : http://www.mozdev.org/pipermail/vimperator/2008-October/002359.html