23

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?

1
  • The answers in this question are all out of date (which makes sense since they are seven years old) If you landed here from google these are not (as of today) the answers you are looking for Commented Dec 6, 2016 at 2:18

8 Answers 8

15

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.

4
  • 3
    for <C-v> (paste) it should be inoremap
    – hasen
    Commented Jul 31, 2009 at 11:56
  • accepted for the plugin link! which is awesome and fixes the issue
    – hasen
    Commented Jul 31, 2009 at 12:05
  • 2
    It looks like the current version (3.8.1) may have C-c and C-v doing OS-level copy and paste by default... I wasn't able to find anything about it in the changelogs, but I just switched from Pentadactyl to latest Vimperator and C-c and C-v worked like I wanted them to.
    – floer32
    Commented Dec 28, 2013 at 16:28
  • @hangtwenty seems to be correct, the answer here is now outdated Commented Dec 6, 2016 at 2:16
35

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.

2
  • Thank you for this comment. This is exactly what I needed to get my head round vimperator and form fields.
    – user120041
    Commented Mar 6, 2012 at 7:16
  • @RevAaron when you enter TEXTAREA mode is this like the traditional VI envronment and most VI key would work for editing text? And also I noticed ( again by accident ) when I press "d" and then "s" or "a" in the TEXTAREA mode it turns the mode to the one called VISUAL. I would appreciate it if you could give me some info on this. or even if you like I can put it as a question then you can answer it then others would use it.
    – Mehrad
    Commented Feb 26, 2014 at 23:45
13

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

2

I've been looking for a way to do this for a while. Nice one. But the noremap solution from user4126 wasn't quite perfect if I wanted to paste into the commandline or into a text box as joe points out. So I tweaked it with inoremap,and cnoremap too over at http://charlieharvey.org.uk/page/vimperator_cut_and_paste . It doesn't look like vnoremap is supported.

So, you can paste into the commandline and into text boxes by using the ctrl-v shortcut only once. Paste the following in your .vimperatorrc and restart Firefox.

noremap <C-v> <C-v><C-v>
inoremap <C-v> <C-v><C-v>
cnoremap <C-v> <C-v><C-v>

noremap <C-c> <C-v><C-c>
inoremap <C-c> <C-v><C-c>
cnoremap <C-c> <C-v><C-c>
2

I didn't find the answers given useful as I cannot see Ctrl+c anywhere. What I do is to use the SecureCRT shortcut. That is, for copying from the page:

Ctrl+Ins

For pasting: Ctrl+V twice (as somebody says in the answers elsewhere).

1
  • Thank you, kind sir. Mapping <c-c> to <c-ins> solved my particular flavour of this problem. Commented Jun 4, 2013 at 0:35
1

Try the following if you'd rather have a mouseless experience than a full-on vim experience:

1
  • NextPlease is for FireFox 3.6 now :) Commented Feb 10, 2010 at 15:57
1

For a short answer - ^V^V (ie. Ctrl-V Ctrl-V)

The first Ctrl-V does "next keystroke pass through". The second Ctrl-V pastes the text. This is what I do for most text fields.

If you use the vi mode for multiline text fields (set noinsertmode), you can also paste using p - so if I wanted to paste the URL of another tab into this tag I can go to that tab, use y and then move back to this tab. The bottom bar of the browser will say -- TEXTAREA -- and I can press p to paste in the URL.

0

I would suggest to use the

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

Because if you have opened a external text editor, a simple C-c at FF window will end the external editor and you will lose everything.

BR

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .