[Malvern] The Vi editor.

Phil Ironside phil at creativespaces.co.uk
Sun Nov 14 12:16:34 GMT 2004


On Sun, 14 Nov 2004 08:55:34 +0000
Geoff Bagley <geoff.bagley at btinternet.com> wrote:

> 
> 
> I am editing  the source code of a programme,  and wish to edit another file, 
> select part of the code,  and then insert it in the prog I am editting.  
> 
> I.e., I want to re-use some code from another prog, and insert it.
> 
> I have searched the man pages of both nano and Vi,  but can,t find the bit 
> about marking, and then moving a block of  text.
> 


Hi Geoff 

For a vim tutorial open vi then type :help version6
move curser of blue link ctrl ] to follow link
then to go back ctrl t

Here is a quick tute

open first file

vim /home/geof/somefile.pl

type  :e /home/geof/someotherfile.pl

press ctrl ^ to switch between files

place curser where you want to start copying (yank)
press v to go into visual select mode
move curser to the end of where you want to copy
press y
press ctrl ^ to swap to the other file
place curser where you want to paste the code
press p

It is easier to copy and paste whole lines at first.

type :w to save to file, remember to make back ups before you start editing incase vim does what it says on the tin - wipes it clean.

You can also copy and paste by lione numbers but that is a bit more complicated to explain.

Here is a link to a good reference

http://www.hk8.org/old_web/unix/vi/

Have booked the table for 8.00 see you then

-- 
Phil Ironside
01684-561495




More information about the Malvern mailing list