If you are using vim as editor and you are using vim inside a pseudo-terminal such as PuTTY, you might have less trouble with copy and paste function as you can use your mouse to highlight text, copy, and paste it inside the file.
However, if you have difficulty copying multiple lines in vim without access to mouse, or in tty, you might want to utilize the command ‘v’ or ‘V’.
To yank (copy) multiple lines:
1) Place the cursor on the first position of the first line you want to yank.
2) In vim command mode, press ‘v’ (without the quotes). You will notice that the message “– VISUAL –” will appear on the lower left part of the screen. This is an indicator that you are now in ‘Visual’ mode.
3) Use your arrow keys to move the cursor to highlight the lines of texts you want to manipulate.
4) After highlighting, press the ‘y’ key to yank (copy) the highlighted lines. You will notice the message similar to “9 lines yanked” on the lower left side of the screen. This means you have successfully copied the lines and ready to be pasted!
5) Place your cursor on the line you want to insert your copied lines to and press ‘p’ to paste below the cursor, or ‘P’ to paste above the cursor.
If you would rather cut the lines, press ‘d’ instead of ‘y’.
Subscribe to Email Feeds
- Vim: How to Copy Multiple Lines
- Required Packages for Oracle 11gR2 on Red Hat Enterprise Linux 6
- How Replace Space with Newline in Vim
- How to Add or Remove Library Path in RHEL | PinoyTux Weblog on What are Libraries in Linux?
- 博文：《RHEL4 安装yum》 - 苗乡小鱼的博客 on Howto: Install yum On RHEL 4
- Hiding Files Inside An Image in Linux | SACHIN JINDAL'S BLOG on Hide Files Inside An Image File
- Falko on Howto: Install yum On RHEL 4
- Akira on Cebu Pacific Airlines is Evil!