Vim Text Editor Cheat Sheet

Listen to this Post

If you use Vim regularly or want to learn it on Linux, this cheat sheet offers a quick reference to essential commands and shortcuts. Find high-res PDF books with all Linux-related infographics at https://study-notes.org.

You Should Know:

Here are some essential Vim commands and shortcuts to enhance your productivity:

Basic Navigation:

– `h` – Move cursor left
– `j` – Move cursor down
– `k` – Move cursor up
– `l` – Move cursor right
– `0` – Move to the beginning of the line
– `$` – Move to the end of the line
– `gg` – Move to the start of the file
– `G` – Move to the end of the file

Editing Commands:

– `i` – Insert mode before the cursor
– `a` – Insert mode after the cursor
– `o` – Insert a new line below the current line
– `O` – Insert a new line above the current line
– `x` – Delete the character under the cursor
– `dd` – Delete the current line
– `yy` – Yank (copy) the current line
– `p` – Paste the yanked text after the cursor
– `u` – Undo the last action
– `Ctrl + r` – Redo the last undone action

Search and Replace:

– `/pattern` – Search for a pattern in the file
– `n` – Move to the next match
– `N` – Move to the previous match
– `:%s/old/new/g` – Replace all occurrences of `old` with `new` in the file

Saving and Exiting:

– `:w` – Save the file
– `:q` – Quit Vim
– `:wq` – Save and quit
– `:q!` – Quit without saving changes

Advanced Commands:

– `:split` – Split the window horizontally
– `:vsplit` – Split the window vertically
– `Ctrl + ww` – Switch between split windows
– `:set number` – Display line numbers
– `:set nonumber` – Hide line numbers

What Undercode Say:

Mastering Vim can significantly improve your efficiency when working with text files on Linux. Practice these commands daily to build muscle memory. Additionally, explore advanced features like macros (q), visual mode (v), and plugins to customize your workflow. For further learning, check out Vim’s official documentation or interactive tutorials like Open Vim.

Remember, Vim is a powerful tool, and proficiency comes with consistent practice. Happy coding!

References:

Reported By: Xmodulo Vim – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

Whatsapp
TelegramFeatured Image