This is a user contributed FAQ.
Q. I'm just starting in vim text editor but I'm annoying typing and retyping similar statements. Can you address me about it?
A. Yes. Vim offer several functionalities that improve your editing. Here are some of them.
1. Copying a whole line
yy or shift y or :ny
where n is the number of line if n is not specified then copy the current line
2. Copying from current position to end of line.
3. Copying 3 lines after the current position
4. Copying a range of line
:1,5y or :1y 5
The above example copy 5 lines, from 1 to 5
5. Deleting a whole line (Deleted line is copy to the registers)
dd or :nd
Where n is the number of line if n is not specified then delete the current line
6. Deleting from current position to end of line (Deleted text is copied to the registers)
d$ or shift d
7. Deleting a range of line
:1,5d or :1d 5
The above example remove 5 lines, from 1 to 5 and copy them to a register
8. Put n times a text, previously copied, after the cursor:
9. Put n times a text, previously copied, before the cursor
n Shift p
10. Word completion, works in insert mode
- Ctrl n search forward for next matching
- Ctrl p search backward for previous matching
Very useful in programming (perl, bash, java, other)
11. Put vim in replace mode
14. Repeating last change
15. Getting help about a topic
Note: previous commands work in command mode except 10.
This article / faq is contributed by Yoander Valdés Rodríguez (yoander). nixCraft welcomes readers' tips / howtos.TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!
- 30 Cool Open Source Software I Discovered in 2013
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop