LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   gvim cut/copy-paste (https://www.linuxquestions.org/questions/linux-newbie-8/gvim-cut-copy-paste-374760/)

arunswarup 10-19-2005 02:01 PM

gvim cut/copy-paste keyboard shortcuts
 
Hi,

suppose i want to copy some text from firefox to gvim, the copied text does not get pasted in gvim with keyboard shortcuts;
i've tried the most-likely shortcuts
Ctrl-V, Shift-Ctrl-V, Shift-Insert
none of them work

when I check the gvim 'Edit' menu, the shortcut for Copy is "+gP ... how the hell am I supposed to remember that--let alone hit 4 keys sequentially---just to Paste from the clipboard?

how do I do a keyboard mapping to Ctrl-V or something sensible

P.S. what were the developers thinking?

Tinkster 10-19-2005 02:39 PM

They were thinking: we want to keep vi the cool, lean
mean editor it always was, and don't annoy the people
who were using it for 20 plus years. Instead of looking
to re-define the thing (always a bad idea, if you get onto
someone elses machine it will "misbehave" again, just
get over it and learn). You COULD conceivably try (I
don't use gvim, just plain vim in an xterm/console) using
X's mouse-way of copying and pasting. High-light in
firefox with the mouse-button1 pressed, switch to gvim,
press i, and middle click into it.


Cheers,
Tink

arunswarup 10-19-2005 03:04 PM

customize keyboard shortcut
 
ok ...

Shift-Insert works on X-term, gnome-terminal, konsole, (even in win XP) ... so, are the shortcut keys dependent on the terminal (in this case gui?)?

how do I set the shortcut key for "paste" to be Ctrl-V?

thank you for replying

edit: if they have a complicated shortcut-setup & expect me to use the mouse (i found the middle-mouse-click quite annoying & i posted in this forum), what is the point of using gvim?

Tinkster 10-19-2005 03:15 PM

I don't know - that's why I don't use it. But if you
dislike (g)vims key-setup, why don't you use kate
or some other more CUA compliant editor instead
of complaining about a screwdriver not being a
hammer?


Cheers,
Tink

acid_kewpie 10-19-2005 03:21 PM

ok... SO... Ctrl+V for paste is good? Ctrl+X for cut is good? well... they're just arbitrary choices just like vi's are... but what about the generic windows hotkey for copy? Ctrl+C? you honestly think that using exactly the same key combination for "copy the selected text" and "terminate this running process immediately" is a good thing?!?!?!?! cha! DOS was using Ctrl+C to terminate programs long before Notepad and it's ilk came around...

Anywho. vi rocks, and it's not until you take the time to look at it in a little more depth that you have a chance of understanding why.

arunswarup 10-19-2005 03:32 PM

*newbie looks at experienced unix users' posts & thinks!*

ook! :D :)

but, they could have assigned something simpler than "+gP

femistofel 10-23-2005 04:42 PM

Quote:

Originally posted by arunswarup
*newbie looks at experienced unix users' posts & thinks!*

ook! :D :)

but, they could have assigned something simpler than "+gP

add the following to your ~/.vimrc:

Quote:

nmap <C-V> "+gP
imap <C-V> <ESC><C-V>i
vmap <C-C> "+y
and don't listen to the conservatives

this assigns Ctrl+V to paste the clipboard in normal and insert modes and Ctrl+c to copy to clipboard in "visual" mode.

srikanth.vittal 09-12-2009 07:34 AM

Cool! Modifiying the .vimrc works.

Thanks

femistofel 09-12-2009 01:52 PM

By the way, there are scripts in the standard distribution that define this and other "compatibility" niceties. If you're used to ms windows "standards" you can add

Code:

source $VIMRUNTIME/mswin.vim
to your ~/.vimrc . For mac compatibility that'd be

Code:

source $VIMRUNTIME/macmap.vim
You can find more interesting standard scripts by browsing the $VIMRUNTIME, just type:

Code:

:vi $VIMRUNTIME

srikanth.vittal 09-13-2009 10:05 PM

Thank you so much. I am settling on mswin.vim.

joar 06-01-2012 07:34 AM

thnx, though I found that:
nmap <C-V> "+gP
imap <C-V> <ESC><C-V>a
vmap <C-C> "+y

using a (append) instead of i (insert) put my cursor behind what I've pasted worked better for me(even adding a space after a) .

ryanpcmcquen 03-08-2014 10:35 PM

'<Ctrl - R> +' will paste the X11 buffer. You can just hold Ctrl and Shift then hit 'R' and '+'.

sugatang itlog 07-21-2014 09:38 PM

@ femistofel, YOU ROCK!

checking the contents of the VIMRUNTIME, so I could add some vim and gvim kung fu. Hehehe!

coupure 06-29-2016 09:09 AM

modify the .vimrc workd fine
 
Thanks. I've always desiring to make the paste shortcut "ctrl+v" work since several months. I managed to get the "ctrl+v" work by modifying the file .vimrc.
ps: it is important to stick to the question asked instead of saying some bullshit (like acid_kewpie)

rjlabs 03-05-2022 12:11 PM

femistofel post was excellent! Have a look at the scripts - very interesting and just what I needed. Wonder why these are not part of the standard gVim install as suggested / endorsed options? vi is as old as the 80 column IBM punch card and 24 line by 80 character monochrome phosphorus dot CRTs (...in amber if you were really living large!) While still retaining excellent "line oriented" features Vi needs to better integrate the technologies that came after the 70s without selling out its original (high speed/hands on) design philosophy - multiple instances of the same and different programs, whole pages of text, paragraphs (indenting, comment out, etc), easier help maneuvering at high speed inside long lines, mouse/touchpad events, user modifiable quick access tool bar with easily programmed hot keys, gestures, modern local/on-line help system, etc. Above scripts are a great start but more evolution eventually needs to occur.


All times are GMT -5. The time now is 09:36 PM.