Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Both neovim-gtk & gnvim are great but don't integrate nicely with standard ctrl + c, ctrl + v actions which is super frustrating.

VSCode with vim plugin handles this well with the Use Ctrl Keys option set. If you're in insert mode, ctrl + v will paste, otherwise ctrl + v will start visual mode. If you are selecting text, ctrl + c will copy.



You can create mappings for that.

Adding a bazillion one-off options like "Use Ctrl Keys" to avoid creating mappings, defeats the purpose of using vim, since creating mappings is the bare minimum way to configure it. (But Vim did so anyways for Windows, in the form of the "mswin.vim" plugin, which is enabled by default, causing confusion for users expecting vim to behave like vim.)


I wouldn't even know where to begin to approach these mappings as they are highly context dependent. If it is possible with just normal vim mappings then that'd be excellent.


    inoremap <C-V> <C-R>+
    vnoremap <C-C> "+y
    cnoremap <C-V> <C-R>+


  vnoremap <C-X> "+ygvd


A different way of tackling this if you don’t mind doing it “the vim way”: Most vim builds enable the + register to access the system clipboard (hopefully these two do so too, I haven’t verified!). “+p = ctrl+v, “+y = ctrl+c etc.

If you’re unfamiliar with registers look them up in the docs they are super useful. (Also have a look at the 0 register, e.g. “0p)


In addition to sibling comment - does any vi(m) work with the (non) standard (for vi) ctrl-v/c out of the box? I understand setting the star/plus as default registry so that paste and yank read/fill the system clipboard. But using ctrl-V for paste is surely alien?

Nothing wrong with custom keybindings, obviously. But it sounds rather non-standard?


Shift + Insert works on every platform I've tried it on. Ctrl-V/C are Unix console commands.


set clipboard+=unnamedplus

imap <C-V> <C-R>+

vmap <C-C> y

Most probably you want this as well:

cmap <C-V> <C-R>+


Worth noting that this is Ctrl+Shift+v and Ctrl+Shift+c.

The C-v (Ctrl+lowercase v) is important for literal character insertion. (Insert a tab, escape, return, etc.)


> The C-v (Ctrl+lowercase v) is important for literal character insertion.

You can remap it to <C-l> (L = literal), and then use <C-c> and <C-v> without shift:

    inoremap <C-l> <C-v>
    imap <C-v> <C-r>+
    cmap <C-v> <C-r>+
    xmap <C-c> "+y


> set clipboard+=unnamedplus

TIL. This goes into my vimrc right now.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: