Vim is a powerful text editor that has been around for over 30 years. It’s known for its efficiency and speed, which is achieved through the use of keyboard shortcuts. If you’re new to Vim, it can be overwhelming to learn all the shortcuts, but with practice, you’ll be able to navigate and edit text like a pro.

Here are some of the essential Vim keyboard shortcuts to get you started:

Moving the Cursor

h: Move the cursor one character to the left.
j: Move the cursor down one line.
k: Move the cursor up one line.
l: Move the cursor one character to the right.
w: Move the cursor to the beginning of the next word.
b: Move the cursor to the beginning of the previous word.
0: Move the cursor to the beginning of the line.
$: Move the cursor to the end of the line.
gg: Move the cursor to the beginning of the file.
G: Move the cursor to the end of the file.
{: Move the cursor to the beginning of the paragraph.
}: Move the cursor to the end of the paragraph.

Editing Text

i: Insert text before the cursor.
a: Insert text after the cursor.
A: Insert text at the end of the line.
o: Insert a new line below the current line and start insert mode.
O: Insert a new line above the current line and start insert mode.
x: Delete the character under the cursor.
dd: Delete the current line.
yy: Yank (copy) the current line.
p: Paste the yanked or deleted text after the cursor.
P: Paste the yanked or deleted text before the cursor.
u: Undo the last command.
Ctrl-r: Redo the last undone command.

Searching and Replacing

/: Search forward for a pattern.
?: Search backward for a pattern.
n: Repeat the last search in the same direction.
N: Repeat the last search in the opposite direction.
:%s/old/new/g: Replace all occurrences of “old” with “new” in the entire file.

Saving and Exiting

:w: Write (save) the file.
:q: Quit Vim.
:q!: Quit Vim without saving changes.
:wq: Write the file and quit Vim.

These are just some of the many keyboard shortcuts available in Vim. As you continue to use Vim, you may find that you want to customize your shortcuts or learn more advanced features. But mastering these essential shortcuts will give you a solid foundation for using Vim efficiently and effectively.

Happy editing!