Master Copy, Cut & Paste in Vim: Complete Commands & Clipboard Guide

While working with any text files in VIM; Copy, cut, and paste is the most common task. Throughout this article, you will know How to Copy, Cut and Paste in Vim/Vi Editor.

Updated: 17 Nov, 25 by Susith Nonis 11 Min

List of content you will read in this article:

Copying, cutting, and pasting text efficiently is one of the most common tasks when working with any text file. For Vim users, mastering these actions can drastically improve productivity, whether you're a beginner navigating the editor for the first time or an intermediate developer managing multiple buffers and files. This article is designed to teach you everything you need to know about copy paste Vim, including advanced use cases, system clipboard integration, and real-life examples.

By the end, you’ll not only know the basic vim cut copy paste commands, but also how to leverage Vim’s registers, visual selections, and clipboard integration across Linux, macOS, and Windows.

Vim operates in multiple modes, each optimized for a different task:

  • Normal Mode: The default mode for navigating, deleting, copying, and executing commands.
  • Visual Mode: For selecting text to perform operations like copying, cutting, or formatting blocks of text.
  • Insert Mode: Used for typing text into the file.

Understanding how to switch between these modes is essential for mastering vim yank and paste operations:

  • Press i to enter Insert Mode.
  • Press Esc to return to Normal Mode.
  • Press v to enter Visual Mode, V for line selection, and Ctrl+v for block selection.

For a deeper comparison of Vim with other editors, check out Vi vs Vim and Vim editor vs Nano editor.

In Vim, copying is referred to as "yanking" text, while cutting is called "deleting," and pasting remains consistent with most editors. Here’s a table summarizing the most common vim cut copy paste commands for different scenarios:

Action

Command

Description

Copy current line

yy

Yanks the entire line including newline

Copy multiple lines

3yy

Yanks three lines starting from the cursor

Copy to end of line

y$

Yanks from cursor to the end of the line

Copy word under cursor

yiw

Yanks the word the cursor is pointing to

Copy inside brackets

y%

Yanks all text between matching brackets ((), {}, [])

Cut current line

dd

Deletes the line including newline

Cut multiple lines

3dd

Deletes three lines starting from cursor

Cut to end of line

d$

Deletes from cursor to end of line

Paste after cursor

p

Pastes yanked or deleted text after the cursor

Paste before cursor

P

Pastes yanked or deleted text before the cursor

These commands are the foundation of how to copy text in Vim, but mastering them in different modes and integrating with system clipboards makes them much more powerful.

Visual Mode is essential for selecting a block of text before copying or cutting. Unlike Normal Mode, Visual Mode allows you to select characters, words, lines, or blocks efficiently:

Copying in Visual Mode

  1. Press v to enter character-wise selection, V for line-wise, or Ctrl+v for block-wise selection.
  2. Use arrow keys or movement commands (h, j, k, l) to highlight the text.
  3. Press y to yank (copy) the highlighted text.

Cutting in Visual Mode

  1. Enter Visual Mode as described above.
  2. Highlight the text you want to cut.
  3. Press d to delete the selection. This also copies it to the default register, allowing you to paste immediately.

Pasting in Visual Mode

  1. Move the cursor to the target location.
  2. Press p to paste after the cursor or P to paste before the cursor.

Visual Mode is especially useful when copying multi-line code snippets or making block edits, which is a common scenario for developers and sysadmins. 

Vim stores copied and deleted text in registers, which are temporary storage locations. By default, commands like y or d use the unnamed register ("), but Vim provides named and system registers for advanced operations:

  • "a to "z — named registers
  • "+ — system clipboard register
  • "* — primary selection (common in Linux X11 environments)

Examples:

  • Yank text to register a: "ayw
  • Delete text to register b: "bdw
  • Paste from register a: "ap

Using registers allows cross-file copy-paste operations and prevents overwriting your default clipboard when performing multiple edits. For beginners, registers might seem complex, but once mastered, they dramatically improve vim clipboard integration.

Read more: Explore How To Select All In Vim/Vi Editor for efficient full-text operations.

Clipboard integration allows Vim to interact with the system clipboard. This means you can copy text in Vim and paste it in another application (or vice versa).

Common Clipboard Commands:

  • Copy to system clipboard: "+y
  • Paste from system clipboard: "+p
  • Copy to primary selection (Linux): "*y
  • Paste from primary selection: "*p

Tip: On macOS and Windows, "+ works reliably for integrating Vim with the OS clipboard. Linux users may need vim-gtk or vim-gnome for full clipboard support.

One of Vim’s strengths is the ability to work with multiple files and buffers efficiently. Once you understand vim yank and paste, you can seamlessly copy text between files without leaving the editor.

Copying Between Buffers

  1. Open multiple files in Vim: vim file1 file2.
  2. Switch between buffers using :bnext (next buffer) and :bprev (previous buffer).
  3. Yank text in one buffer using y or visual selection commands.
  4. Switch to the target buffer and paste using p or P.

Copying Between Files

  • You can also use named registers to preserve your yanked text while switching files:
    • Yank into register a: "ay
    • Switch file and paste: "ap

This method ensures you do not overwrite your clipboard contents when performing complex multi-file operations.

Tip: Using vim clipboard integration commands like "+y allows copying from Vim directly into other applications, improving productivity for developers and sysadmins.

Understand How to search in VIM/VI Editor to quickly locate text in large files.

While most Vim users paste in Normal Mode, there are times when pasting in Insert Mode is necessary, especially when maintaining the flow of typed text.

Steps:

  1. Enter Insert Mode with i.
  2. Use the system clipboard register for pasting: Ctrl+Shift+V in terminal-based Vim (Linux) or "+p in GUI Vim.
  3. Press Esc to return to Normal Mode.

Common Pitfall: Pasting in Insert Mode can cause auto-indentation issues. To avoid this, use :set paste before pasting and :set nopaste after. This disables Vim’s automatic indentation temporarily.

Even experienced Vim users encounter issues when copying and pasting. Here are common problems and solutions:

1. Paste Not Working from System Clipboard

  • Ensure your Vim version has clipboard support: run vim --version | grep clipboard. Look for +clipboard or +xterm_clipboard.
  • Use "+y to copy and "+p to paste if system clipboard integration is supported.

2. Indentation Changes on Paste

  • Use :set paste before pasting, then :set nopaste after.

3. Accidentally Overwriting a Register

  • Use named registers ("a to "z) to save important yanks or deletes.

4. Undo/Redo After Paste

5. Copying Between Remote Sessions

  • Use system clipboard commands ("+y and "+p) when working in GUI Vim or with vim-gtk on Linux.

Here’s a consolidated table for beginners and intermediate users to keep handy while working with Vim:

Action

Command

Notes

Copy (Yank) line

yy

Includes newline

Copy multiple lines

3yy

Number of lines can be changed

Copy word under cursor

yiw

“inner word”

Copy inside brackets

y%

Useful for functions, arrays

Cut (Delete) line

dd

Includes newline

Cut multiple lines

3dd

Deletes 3 lines starting at cursor

Cut to end of line

d$

Deletes from cursor to line end

Paste after cursor

p

Can be in Normal or Visual Mode

Paste before cursor

P

Can be in Normal or Visual Mode

Yank to system clipboard

"+y

Requires Vim with clipboard support

Paste from system clipboard

"+p

Ensures cross-application paste

Undo

u

Undo last change

Redo

Ctrl+r

Redo last undone change

This cheat sheet is essential for anyone learning how to copy text in Vim efficiently and avoiding common mistakes.

Here are a few practical scenarios where mastering copy paste Vim is especially useful:

  • Developers: Copying a function from one file to another without leaving Vim.
  • Sysadmins: Extracting log snippets across multiple configuration files.
  • Writers: Reorganizing text sections or moving paragraphs efficiently.

Additionally, using visual mode selection combined with named registers or system clipboard integration can save time and prevent errors when working with long scripts or large documents.

Learn How to Delete line in Vim/Vi Editor for fast line removal techniques.

Mastering copy paste Vim is more than knowing a few commands; it’s about understanding modes, using registers effectively, integrating with system clipboards, and handling multi-file workflows efficiently. By practicing vim yank and paste in Normal, Visual, and Insert Modes, you can drastically improve your productivity as a developer, sysadmin, or writer.

Remember to use the cheat sheet for quick reference, leverage named and system registers, and explore advanced techniques like copying between buffers or using clipboard integration across platforms. Also for Linux users optimizing Vim workflows, consider Linux VPS for a dedicated development environment.

 

People are also reading:

Yes! Use "+y to copy to the system clipboard and "+p to paste from it.

y (yank) copies text without removing it, while d (delete) removes the text but also stores it in a register for pasting.

Use :set paste before pasting, then :set nopaste after to restore automatic indentation.

Prefix yy with a number, e.g., 3yy to copy three lines at once.

Registers store yanked or deleted text. Named registers allow you to manage multiple pieces of text simultaneously without overwriting your clipboard.

Susith Nonis

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.

user monovm

Matteo Kautzer

2025, Jan, 25

This guide is perfect for anyone looking to boost their efficiency with Vim. The breakdown of commands for copying, cutting, and pasting is incredibly helpful, especially for those transitioning from other text editors or just getting started with Vim. The visual mode tips are a nice addition too. It's great to see powerful tips laid out in such a straightforward manner. Keep up the awesome work!

user monovm

Dr. Karli Ruecker

2025, Mar, 25

This article is a fantastic resource for anyone looking to enhance their Vim skills. Vim can seem a bit intimidating at first, but the step-by-step instructions for copy, cut, and paste make it much more approachable. Understanding both visual and normal modes along with keyboard shortcuts really boosts efficiency. Thanks for breaking it down so clearly, it’s incredibly helpful for streamlining text editing tasks!

user monovm

Michele Shanahan Jr.

2025, Sep, 25

Great post on mastering Vim! It's awesome to see such a comprehensive guide on copying, cutting, and pasting in Vim, especially with both visual and normal modes. These commands are truly essential for anyone looking to boost their efficiency and productivity while editing text. The inclusion of keyboard shortcuts is particularly helpful, and I appreciate the detailed explanations. Keep up the fantastic work, and thank you for sharing such valuable information.

user monovm

Noemy Lynch

2025, Sep, 25

Great article! Vim can be intimidating at first, but once you get the hang of it, it's incredibly powerful and can significantly boost productivity. Your breakdown on copying, cutting, and pasting commands, especially in both visual and normal modes, is super helpful. It's great to see the emphasis on keyboard shortcuts too, as they are essential for efficient editing in Vim. For anyone diving into Vim for the first time, this guide is a fantastic starting point. Keep up the great work!

user monovm

Vergie Feeney

2025, Oct, 25

Great article on mastering basic commands in Vim! It's wonderful to see such a detailed explanation of the copy, cut, and paste functionalities. Vim can be intimidating to newcomers, but resources like this make it so much more accessible. I especially appreciated the breakdown of visual and normal modes. Understanding these will significantly improve anyone's productivity in Vim. Looking forward to implementing these tips—thanks for sharing!

user monovm

Ricky Rohan

2025, Oct, 25

Great article on navigating Vim's powerful editing capabilities! For those diving into Vim for the first time, mastering these copy, cut, and paste commands can significantly streamline your workflow. The breakdown into visual and normal modes is really insightful, helping users understand the flexibility Vim offers. Can't wait to try out these commands and improve my efficiency. Keep up the good work in demystifying Vim's potential for beginners and advanced users alike!