HELP: COPY IN VIM

9 views
Skip to first unread message

Kunal Chauhan

unread,
May 2, 2020, 3:49:02 AM5/2/20
to vim...@googlegroups.com
Hi Team,
Some time I need to copy some text from one vim file and need to copy it in another in same directory. 


1. How can i achieve this?

2. Can I open both file simultaneoulsy and do the copy code from one to another in vim


Thanks
Kunal


Tony Mechelynck

unread,
May 2, 2020, 4:27:01 AM5/2/20
to Kunal Chauhan, vim_use
1. See below
2. Yes:

If your Vim is compiled with +windows (which is always the case if
your Vim is at version 8.0.1118 or newer) just open both files in
split-window mode, either by starting Vim or gvim as (for instance)

vim -o2 filename1 filename2

or (if you already have filename1 open in Vim)

:split filename2
or
:new filename2

then yank in the one and put into the other. The fact that both files
are in the same directory is irrelevant here, as long as you can
access them both (and write the changed one) from a single computer.
(Either filename1 or filename2, or both, can be a full
path-file-name.)


Best regards,
Tony.

Chris Willis

unread,
May 2, 2020, 5:15:20 AM5/2/20
to vim...@googlegroups.com, Kunal Chauhan, vim_use
From: Tony Mechelynck
Sent: Saturday, May 02, 2020 9:26 AM
To: Kunal Chauhan
Cc: vim_use
Subject: Re: HELP: COPY IN VIM
--
Hi Kunal

you will also need to know how to move between the windows. That's CTRL + w
followed by a cursor key ( or CTRL + w followed by one of hjkl (for
horizontal splits as described by Tony, one of jk)).

Chris

Tony Mechelynck

unread,
May 2, 2020, 7:34:40 AM5/2/20
to vim_use, Kunal Chauhan
Yes. Or Ctrl-W w goes to the next window (round-robin) in displayed
sequence, Ctrl-W W to the previous one (but either of them with a
count go to the nth from top, not the nth from where you are), and
mouse-clicking in any window or on its status bar goes to that window.

So if there are only two split-windows, Ctrl-W w (or, if your thumb
moves slowly, Ctrl-W Ctrl-W) goes from either one to the other.

Happy Vimming!
Tony.
Reply all
Reply to author
Forward
0 new messages