Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Vim

You're reading from   Mastering Vim Efficient and effortless editing with Vim and Vimscript

Arrow left icon
Product type Paperback
Published in Jul 2024
Publisher Packt
ISBN-13 9781835081877
Length 300 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ruslan Osipov Ruslan Osipov
Author Profile Icon Ruslan Osipov
Ruslan Osipov
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Chapter 1: Getting Started 2. Chapter 2: Advanced Editing and Navigation FREE CHAPTER 3. Chapter 3: Follow the Leader Plugin Management 4. Chapter 4: Understanding Structured Text 5. Chapter 5: Build, Test, and Execute 6. Chapter 6: Refactoring Code with Regex and Macros 7. Chapter 7: Making Vim Your Own 8. Chapter 8: Transcending the Mundane with Vimscript 9. Chapter 9: Where to Go from Here 10. Index

Copying and pasting with registers

You can copy text by using the y (yank) command, followed by a movement or a text object. You can also hit y from a visual mode when you have selected some text.

Tip

In addition to all of the standard movement, you can use yy to yank the contents of the current line.

Let’s yank the following piece of code by typing ye (yank until the end of the word):

Figure 2.35 – ye will yank (copy) has_spam into the default register.

Figure 2.35 – ye will yank (copy) has_spam into the default register.

This will copy has_spam into our default register. Now, place the cursor where you want the text to appear (the text is inserted after the cursor):

Figure 2.36 – Place cursor before the position where you want to insert the text.

Figure 2.36 – Place cursor before the position where you want to insert the text.

To paste the code, hit p:

Figure 2.37 – p will insert the default register contents after the cursor.

Figure 2.37 – p will insert the default register contents after the cursor.

The delete and change operators also yank content so that you can paste it later...

You have been reading a chapter from
Mastering Vim - Second Edition
Published in: Jul 2024
Publisher: Packt
ISBN-13: 9781835081877
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime