Moving/Copying Sections of Text in vi
Moving and copying sections of text can by done in several ways. The next section shows you how to use marks to do this because it gives you the best control and the most successful results.
Moving/Copying Text in the Same File
To move or copy text within the same file with vi
1. | In vi, move the cursor to the start of the text to move or copy.
|
2. | Type ma.
This command executes without pressing Enter. It sets mark a at that line. If mark a is already in use to mark another line of the file, you can choose any other letter for your mark. You can set up to 26 marks.
|
3. | Move the cursor to the last line of the section to be moved or copied.
|
4. | To move the text, type d'a. This command executes without pressing ... |
Get Practical UNIX now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.