Unlike other text editors, Vim is a keyboard-focused text editor and provides a powerful, efficient, and extremely customizable method of working with text. One of the most essential skills you can acquire while using Vim is becoming familiar with its keybindings, shortcuts. It allows you to jump around, edit, and control text at a quick speed. It is particularly useful for developers, writers, and system administrators.
Where traditional editors introduce a variety of keyboard and mouse-driven navigation and menu options, Vim brings to the table a series of keybindings that allow you to move, select, and edit text as effectively as entirely from the keyboard.
In this guide, we’ll walk you through the most important commands and shortcuts of Vim. Whether you are editing code, writing markdown, or working on plain text files, we will help you master Vim like a professional.
What is Vim and its Keybindings?
Vim (Vi IMproved) is an advanced and highly configurable text editor developed to enable efficient text editing. It’s an enhanced version of the old Unix “vi” editor, and is frequently important for its speed and flexibility.
Vim keybindings Linux enable you to move around, edit, search, and modify text instantly. The fact that Vim is modal, meaning that different keys do different things depending on what mode you are in. It also promotes a more mindful, focused form of working that makes it ideal for anyone who spends a lot of time inside the command line or writing code.
Master Vim Keybindings on Our Ubuntu VPS!
Kickstart your Vim journey using Ultahost’s reliable Ubuntu VPS hosting. Experience smooth setup, fast performance, and expert support!
Vim comes in many forms, modes, each one is for specific types of actions:
Normal Mode: Used for navigation and running commands. Press Esc to return to this mode.
Insert Mode: Used for typing text into the file. Enter this mode using i, a, or o.
Visual Mode: Used to select text blocks. Enter using v, V, or Ctrl+v.
Command-Line Mode: Used to run commands like save or search. Enter using the : key.
Before exploring the Vim keybindings, you should ensure that Vim is installed on your Linux (Ubuntu) system. Ubuntu installs VIM by default, and it is a more enhanced version of Vi with extra features (I prefer that you need to have Vim with full capabilities and keybindings installed on your system). If you don’t have the full VIM toolkit. Let’s install it:
Install Vim
If Vim hasn’t been installed on your system, you can install it easily from the repository using the apt package manager. Run the following command:
sudo apt install vim
This command installs Vim on your system:
Wait until the installation is finished. Now, check its version:
vim --version
If Vim is installed, this will return version information. Otherwise, you may encounter an error, something like Vim command not found.
How to Use Vim Keybindings?
You can open Vim by typing vim now. You see the version info printed, which tells us Vim is installed and ready for use:
vim
This opens an empty file in the Vim editor. You’re now inside Vim. Let’s proceed with the keybindings.
Hit i to get into Insert Mode and begin typing:
Or hit Esc to go back to Normal mode. Now you are ready to experience the power of Vim keybindings:
In Vim, you can use the arrow keys, and/or move with h, l, j, and k is faster:
h: Moves the cursor one character to the left. Example: From He|llo, pressing h moves the cursor to H|ello.
l: Moves the cursor one character to the right. Example: From He|llo, pressing l moves the cursor to Hel|lo.
j: Moves the cursor down to the next line. Example: The cursor moves to the same column on the line below.
k: Moves the cursor up to the previous line. Example: The cursor moves to the same column on the line above.
2. Word & Line Movement
If you are editing text and want to familiarize yourself with line movement, follow the Vim shortcuts below:
w: Jumps the cursor to the beginning of the next word. Example: From Hel|lo world, pressing w moves the cursor to Hello |world.
b: Moves the cursor to the beginning of the previous word. Example: From Hello |world, pressing b moves the cursor to |Hello world.
e: Moves the cursor to the end of the current word. Example: From Hel|lo, pressing e moves the cursor to Hello|.
0: Moves the cursor to the beginning of the current line. Example: From anywhere on the line, pressing 0 moves the cursor to the first character.
^: Moves the cursor to the first non-whitespace character on the line. Example: From |Hello, pressing ^ moves the cursor to the H of Hello.
$: Moves the cursor to the end of the current line. Example: From Hello |world, pressing $ moves the cursor to Hello world|.
gg: Moves the cursor to the beginning of the file. Example: Pressing gg takes the cursor to the first line of the document.
G: Moves the cursor to the end of the file. Example: Pressing G jumps to the last line of the file.
3. Insert Mode Shortcuts
Getting into Insert Mode lets you type normally. Some keybindings to enter Insert Mode:
i: Enters Insert Mode before the current cursor position. Example: From |Hello, pressing i allows typing before the H.
I: Enters Insert Mode at the beginning of the line. Example: The cursor moves to the start of the line for immediate typing.
a: Enters Insert Mode after the current cursor position. Example: From Hel|lo, pressing a allows typing after the l.
A: Enters Insert Mode at the end of the current line. Example: The cursor jumps to the end of the line for typing.
o: Opens a new line below the current one and enters Insert Mode. Example: Pressing o adds a new line below and places the cursor there.
O: Opens a new line above the current one and enters Insert Mode. Example: Pressing O inserts a new line above and starts editing there.
4. Editing and Deleting Text
In Normal mode, you can edit or delete lines in Vim using the following shortcut keys:
x: Deletes the character under the cursor. Example: From He|llo, pressing x deletes l, resulting in Helo.
dd: Deletes the entire current line. Example: Pressing dd removes the full line and shifts the rest upward.
dw: Deletes from the cursor to the end of the current word. Example: From Hello |world, pressing dw results in Hello.
d$ or D: Deletes from the cursor to the end of the line. Example: From Hel|lo world, pressing d$ deletes lo world.
u: Undoes the last change made. Example: After deletion or insertion, pressing u restores the previous state.
Ctrl + r: Redoes the last undone change. Example: Pressing Ctrl + r reapplies the change reversed by u.
5. Copying and Pasting (Yanking and Putting)
In Vim, copying is called “yanking” and pasting is “putting”.
yy: Yanks (copies) the current line. Example: Pressing yy stores the full line into a register for pasting.
yw: Yanks the word under or after the cursor. Example: From |Hello, pressing yw copies Hello.
y$: Yanks from the cursor to the end of the line. Example: From Hel|lo world, pressing y$ copies lo world.
p: Pastes text after the cursor or below the current line. Example: Pressing p pastes the copied content after the cursor location.
P: Pastes text before the cursor or above the current line. Example: Pressing P pastes the copied content before the cursor location.
6. Visual Mode
Use Visual Mode to select text:
v: Starts character-wise visual selection. Example: Pressing v and moving the cursor selects characters individually.
V: Starts line-wise visual selection. Example: Pressing V highlights the entire current line.
Ctrl + v: Starts block (visual column) selection mode. Example: Use Ctrl + v to select a rectangular block across multiple lines.
d: Deletes the selected text in Visual Mode. Example: After selecting text with v, pressing d removes it.
y: Yanks (copies) the selected text. Example: After highlighting, pressing y copies the selection.
> / <: Indents or un-indents the selected text. Example: After selecting lines with V, press > to increase indentation.
7. Search and Replace
If you want to search for some text and replace it with other text, follow the keybindings below for Vim:
/word: Searches forward for a specific word. Example: Typing /main highlights the next occurrence of “main”.
?word: Searches backward for a specific word. Example: Typing ?main finds the previous “main” in the file.
n: Moves to the next search result. Example: After /main, pressing n moves to the next match.
N: Moves to the previous search result. Example: After /main, pressing N jumps to the previous match.
:%s/old/new/g: Replaces all occurrences of a word in the file. Example: :%s/foo/bar/g replaces every instance of “foo” with “bar”.
:%s/old/new/gc: Replaces all with confirmation for each. Example: :%s/foo/bar/gc prompts you before replacing each occurrence.
8. Saving and Exiting
Use Command-Line Mode (press: in Normal Mode):
:w: Saves the current file without closing it. Example: Pressing :w writes your changes to disk but keeps Vim open.
:q: Quits Vim if there are no unsaved changes. Example: Pressing :q exits Vim only if nothing has been modified.
:wq: Saves changes and then quits Vim. Example: Pressing :wq writes the file and exits the editor.
: x: Saves only if changes are made and then quits. Example: Pressing : x is like :wq but avoids unnecessary writes.
:q!: Quits Vim and discards unsaved changes. Example: Pressing :q! forces Vim to exit without saving any edits.
That is all from this Vim basic guide.
Final Thoughts
Vim is the one text editor that an increasing number of developers and Unix users are using. This speeds up your editing and increases your focus on work rather than jumping between many files. Vim appears complex at first. Begin slowly and practice daily, and you’ll soon be editing text faster than you ever thought was possible.
Experience Ultahost’scheap Linux VPS hosting for better performance and reliability at a budget-friendly cost. Ultahost offers complete flexibility and control while handling all server management, ensuring everything runs smoothly and reliably with guaranteed uptime!
FAQ
Is Vim difficult to learn?
Vim is a bit hard to get started with since it is modal, but with practice, it ends up being an intuitive and powerful tool.
How do I exit Vim?
The quickest thing to do would be :wq to save and quit, or :q! to quit without saving. And if you’re not in Normal Mode, press Esc first.
Which keybindings should I learn first?
Begin with movement (h, j, k, l), insert mode (i, a), delete (x, dd), save (:w), and quit (:q).
Can I use the arrow keys in Vim?
You can, but it’s suggested to use h, j, k and l to make it faster and avoid moving your hands.
What is Vim’s Insert Mode?
This is like normal typing, and is called “Insert Mode”. Then, enter with i, a, o and exit with Esc.
Is there a tutorial for learning the visual aspects of Vim?
Yes, VimTutor and applications like “Vim Adventures” do gamify it to a degree.
Can I use plugins in Vim?
Yes. Plugins, such as nerdtree, fzf, and vim-airline, improve functionality. You can install them in a manager like vim-plug.
UltaAI – Smart AI Assistant for Ultahost Clients
UltaAI is Ultahost’s intelligent support assistant, designed to help you manage hosting, domains, billing, and technical issues instantly with smart, AI-powered responses.