As a Vim user, knowing the right commands can make a huge difference in your productivity. Here are 10 essential Vim commands that will help you speed up your text editing tasks:
- Insert Mode – Press
"i"
to enter insert mode, where you can start typing your text. Press"ESC"
to exit insert mode. - Save and Quit – Press
":wq"
to save and quit the current file. You can also use":w"
to save the changes without quitting. - Undo and Redo – Press
"u"
to undo your last action, and"Ctrl+r"
to redo it. - Copy, Cut and Paste – Press
"y"
to copy (yank) the selected text,"d"
to cut (delete) it, and"p"
to paste it. - Search – Press
"/"
followed by the search term to search for it within the file. Use"n"
to move to the next match and"N"
to move to the previous match. - Replace – Press
":s/old/new"
to replace the first occurrence of"old"
with"new"
. Add"g"
at the end to replace all occurrences. - Move Cursor – Use the arrow keys to move the cursor one character at a time. Alternatively, use
"h"
to move left,"j"
to move down,"k"
to move up, and"l"
to move right. - Delete – Use
"x"
to delete the character under the cursor,"dd"
to delete the current line, and “D” to delete from the cursor to the end of the line. - Open and Close Files – Press
":e filename"
to open a file, and":q"
to close it. You can also use":wq"
to save and close the file. - Visual Mode – Press
"v"
to enter visual mode, where you can select text with your cursor. Once selected, you can use commands such as"y"
to copy,"d"
to cut, and"p"
to paste.
These essential Vim commands will help you work faster and more efficiently with text files. Practice them regularly to become a Vim master and take your productivity to the next level!
Additional resources for Vim commands and shortcuts: