Blog » Linux » How to Use Vim Editor in Linux: The Complete Beginner’s Guide
› how-to-use-vim-editor-in-linux

How to Use Vim Editor in Linux: The Complete Beginner’s Guide

Table of Contents

If you’ve spent any time in the Linux world, you’ve probably heard of Vim. Maybe you accidentally opened it and panicked when you couldn’t figure out how to close it. (Don’t worry—we’ve all been there.) Learning how to use Vim editor in Linux is one of those skills that separates casual users from people who truly feel at home in the terminal.

I’ll be honest with you: Vim has a learning curve. But once it clicks, you’ll wonder how you ever edited text any other way. In this guide, I’m going to walk you through everything you need to get started—from understanding what Vim actually is to executing your first commands with confidence.

What is Vim (And Why It’s on Every Linux System)

Before we dive into commands, let’s understand what makes Vim different from every other text editor you’ve used.

The Simple Definition: A Modal Text Editor

Vim is a modal text editor. That single word—”modal”—is the key to understanding everything about Vim. Unlike Notepad, VS Code, or even Nano, Vim operates in different modes. Each mode changes what your keyboard does.

In most editors, pressing “j” types the letter “j.” In Vim’s Normal mode, pressing “j” moves your cursor down one line. This might sound confusing at first, but it’s actually incredibly powerful. It means your entire keyboard becomes a command center for navigating and manipulating text—without ever touching the mouse.

RackNerd Mobile Leaderboard Banner

Get a VPS from as low as $11/year! WOW!

Why It’s Called ‘Vim’ (And How It Differs From Vi)

Vim stands for Vi IMproved. The original Vi editor was created in 1976 by Bill Joy. Bram Moolenaar released Vim in 1991 as an enhanced version with features like syntax highlighting, undo levels, and plugin support. You can download the latest version from the Vim official website.

Here’s the practical part: Vim (or at least Vi) comes pre-installed on virtually every POSIX-compliant system. That means if you SSH into a server, check your Linux version, and need to edit a config file—Vim will be there. No installation required.

My First Vim Experience (And Why I Almost Gave Up)

I still remember my first Vim encounter. It was back when I was running Ubuntu 8.04 on an old ThinkPad. I needed to edit my .bashrc file to set up some environment variables, and some tutorial told me to type vim ~/.bashrc.

So I did. And then… nothing worked like I expected. I pressed keys and random characters appeared. I couldn’t figure out how to save. I definitely couldn’t figure out how to quit. After about ten minutes of frustrated key-mashing, I ended up force-closing the terminal.

If that story sounds familiar, keep reading. I promise Vim makes sense once you understand the modes.

Understanding Vim’s Three Modes (The Key to Everything)

Remember when I said Vim is “modal”? This is where it matters. Vim has three primary modes, and understanding them will prevent 90% of beginner confusion.

Normal Mode: The Command Center

When you first open Vim, you’re in Normal mode. This is Vim’s default state. In Normal mode:

  • Keys execute commands rather than typing text
  • Navigation happens via keyboard shortcuts (h, j, k, l)
  • Text manipulation uses operators like delete (d), yank (y), and change (c)

Think of Normal mode as your command center. You’ll spend most of your time here, jumping around your file and making precise edits. The key insight: you should stay in Normal mode by default and only drop into Insert mode when you need to type.

Insert Mode: Where You Actually Type

Press i in Normal mode, and you enter Insert mode. Now Vim behaves like a regular text editor. Keys type characters. You can write whatever you want.

When you’re done typing, press ESC to return to Normal mode. This ESC key is your best friend in Vim—when in doubt, press ESC.

💡 Quick Tip: There are multiple ways to enter Insert mode:

  • i – Insert before cursor
  • a – Insert after cursor (append)
  • o – Open new line below and insert
  • O – Open new line above and insert

Visual Mode: Selecting and Manipulating Text

Press v in Normal mode to enter Visual mode. This lets you select text by moving the cursor. Once selected, you can delete it (d), copy it (y), or change it (c).

Visual mode is great for when you need to operate on a specific chunk of text. Select your block, then execute your command—it’s intuitive once you try it.

Getting Started with Vim: Your First Session

Enough theory. Let’s actually use Vim.

Opening Files with Vim

Open your terminal and type:

vim filename.txt

If the file exists, Vim opens it. If it doesn’t exist, Vim creates a new buffer with that name. You’ll see tildes (~) on empty lines—that’s Vim telling you those lines don’t exist yet.

This is how you’d edit SSH configuration files, cron jobs, or any config file on your system.

The vimtutor: Your Built-In Teacher

Here’s something most beginners don’t know: Vim comes with an interactive tutorial. Just type:

vimtutor

This launches a 30-minute guided lesson that teaches you the fundamentals by having you actually practice them. I recommend running through it at least once. It’s how I finally “got” Vim after my initial frustrations.

Essential Vim Commands You Need to Know

You don’t need to memorize hundreds of commands. Focus on these essentials, and you’ll handle 80% of editing tasks.

Navigation Commands (Moving Without Arrow Keys)

Yes, Vim uses h, j, k, l instead of arrow keys. It sounds weird, but your fingers never leave the home row:

  • h – Move left
  • j – Move down
  • k – Move up
  • l – Move right
  • w – Jump to next word
  • b – Jump back a word
  • 0 – Jump to beginning of line
  • $ – Jump to end of line
  • gg – Jump to top of file
  • G – Jump to bottom of file

The arrow keys still work if you prefer them—especially when starting out. But try to practice hjkl. After a week, it becomes muscle memory.

Editing Commands (The Real Power)

These are the commands that make Vim feel like magic once you learn them:

  • i – Enter Insert mode (start typing)
  • ESC – Return to Normal mode
  • x – Delete character under cursor
  • dd – Delete entire line
  • dw – Delete from cursor to end of word
  • yy – Yank (copy) entire line
  • p – Paste after cursor
  • u – Undo last change
  • Ctrl+r – Redo

Here’s where it gets powerful: commands combine with motions. d5j deletes 5 lines down. y3w copies 3 words. This grammar-like system is why Vim users can edit so fast.

Saving and Quitting (The Exit That Confuses Everyone)

The infamous “how do I exit Vim” question has become a meme for good reason. Here’s the answer:

🚪 Exit Commands (Memorize These):

  • :w – Save (write) file
  • :q – Quit (only works if saved)
  • :wq – Save and quit
  • :q! – Quit without saving (force quit)

The colon (:) enters “Command-line mode” where you type these commands. Press Enter to execute. If you remember nothing else from this article, remember :q!—it’s your emergency exit when things go wrong.

Searching in Vim

Need to find something? Press / followed by your search term:

/error

Press Enter, and Vim jumps to the first match. Press n to go to the next match, or N for the previous one. This search uses patterns similar to the grep command you might use elsewhere in Linux.

Vim vs Nano: Which Should You Use?

People ask me this all the time. Here’s my honest take.

Nano is simpler. Commands are displayed at the bottom of the screen. There are no modes to confuse you. For quick, one-off edits—like changing a single line in a config file—Nano works fine.

Vim requires upfront investment. But once you’re comfortable, you’ll edit text faster than you ever thought possible. According to Stack Overflow’s developer survey, about 27% of developers use Vim regularly. That’s a lot of people who’ve decided the learning curve is worth it.

My recommendation: Use Nano when you need something quick and don’t want to think. Use Vim when you’re doing serious editing work—writing scripts, managing configs, or anything repetitive where efficiency matters.

“Since Vim is open-source and freely distributable, users don’t have to pay to use it. Even so quite a few people who use Vim regularly expressed to me that they wanted to reward me for my work in some way.”
Bram Moolenaar, Vim Creator

Common Vim Mistakes (And How to Avoid Them)

After years of helping folks in Linux user groups, I see the same mistakes repeatedly:

  • Typing in Normal mode: You press keys expecting text, but Vim executes commands instead. Always check which mode you’re in (it shows at the bottom).
  • Not knowing :q!: When you’re stuck and confused, :q! exits without saving. Memorize it.
  • Ignoring ESC: When in doubt, press ESC. It always returns you to Normal mode—a safe place to reorient.
  • Forgetting to save: Vim doesn’t auto-save. Use :w frequently, or you’ll lose work.
  • Learning too much too fast: You don’t need every command. Master the basics first.

For complete command reference, bookmark a Vim cheat sheet and refer to it as needed.

Next Steps: Becoming a Vim Power User

Once you’re comfortable with the basics, here’s where to go next:

  • Customize your .vimrc: This config file lives in your home directory. Add line numbers, set your colorscheme, enable syntax highlighting. You can also create shell aliases in your .bashrc to customize how you launch Vim.
  • Learn operators + motions: Commands like ci" (change inside quotes) or da( (delete around parentheses) become second nature with practice.
  • Run vimtutor again: Seriously. The second time through, you’ll pick up things you missed.
  • Explore Neovim: The Neovim project is a modernized Vim fork with better defaults, Lua scripting, and faster startup times. Many users are making the switch.

The official Vim documentation is excellent once you’re ready to go deeper. It covers everything from basic commands to advanced scripting.

Wrapping Up

Learning Vim isn’t about memorizing commands—it’s about building a new way of thinking about text editing. Start small. Use vimtutor. Practice the basics until they’re automatic. Then gradually add more commands to your toolkit.

Will it feel awkward at first? Absolutely. But stick with it, and you’ll have a skill that works on any Linux system, any server, anywhere. That’s the beauty of Vim—it’s been around since 1991, and it’ll be around long after the trendy editors fade away.

If you’re building out your Linux skills, check out our other guides on searching files with grep and scheduling cron jobs. Each one builds on your terminal comfort level—and they all assume you can edit a config file with confidence.

You’ve got this. Happy editing. 🐧

author avatar
Alexa Velinxs
I'm Alexa Velinxs, a cryptocurrency trading expert passionate about demystifying digital assets for both beginners and seasoned investors. Through my writing, I share actionable strategies, market insights, and practical tips to help you navigate the crypto landscape with confidence. Let's explore the future of finance together.
Related Posts