0

I'm trying to use ac to copy the whole contents to the system clipboard in gVim. Putting this in my .vimrc isn't working:

nnoremap <leader>ac ggvG$<C-Insert>

If I manually press ggvG$[Ctrl-Insert] from normal mode, it works as expected: goes to the top, selects to the bottom, copies it all, and drops me in normal mode at the top of the file.

When I set nnoremap <leader>ac ggvG$<C-Insert> in my .vimrc, and then activate it (with [Space]ac), it selects from the top to the bottom, beeps an error, and then just sits there in visual mode with the whole file selected.
If I manually press [Ctrl-Insert] at that point, it finishes as expected. So I'm pretty sure vim's just not doing the <C-Insert> part.

I further tested by adding this vnoremap <leader>ci <C-Insert>.
I selected a word or a line in visual mode, activated that map, and got a beep and no copying. A manual [Ctrl-Insert] works fine.

So why can't I map to <C-Insert>?

2

help c-insert will tell you that "*y will do the same as <C-Insert>.

So try

nnoremap <leader>ac ggVG"*y

(using V as it makes more sense)

While I didn't check, Vim says it's a standard DOS mapping so

nmap <leader>ac ggVG<c-insert>

may work as well.

  • Thanks! Both of these worked: nmap <leader>ac gg<S-v>G<C-Insert> and nnoremap <leader>ac gg<S-v>G"*y. This one didn't, despite what the help file says: nnoremap <leader>ac gg<S-v>G<M-N><M-U>. – Jacktose Mar 19 '17 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.