Text Editing With Vi/Vim: What LFCS Actually Expects You to Know

By LinuxCert.Guru Team·

Objective

This guide covers vi/vim from the ground up, specifically for LFCS preparation. By the end, you will know:

  • How vim's modes work and why this trips up nearly every beginner
  • The exact navigation, editing, and search commands you'll actually use under exam time pressure
  • How to save, quit, and recover from mistakes without panicking
  • Why vi/vim is a direct LFCS objective, not just a "nice to have" skill

You SSH into a remote server. There's no desktop, no GUI, no gedit, no fallback. You need to edit a config file right now. On almost every Linux system you'll ever touch as an administrator, vi or vim is what's there. The LFCS exam is built around that exact reality, and it expects you to be fluent, not just familiar.

Why the LFCS Exam Cares About This

The LFCS is a performance-based exam. You get a live terminal, a list of tasks, and a time limit, no multiple choice, no GUI tools to lean on. Nearly every task that involves a configuration file, a service definition, or a script requires you to open it, change it, and save it correctly, under time pressure, without a mouse.

This is also explicitly recognized outside the LFCS itself. The Linux Foundation offers a standalone "Text Editing with Vim" credential precisely because vim fluency is treated as foundational, not optional, for anyone working toward LFCS or similar certifications. If you're slow in vim, every single task on the exam takes longer than it needs to, not just the ones that look like editing tasks.

vi vs Vim: What You're Actually Using

vi is the original, minimal text editor that's been part of Unix-like systems for decades. Vim ("Vi IMproved") is a modern, backward-compatible extension of vi with more features: syntax highlighting, better undo, visual mode, and more. On nearly every current Linux distribution, the vi command is actually aliased to vim, so in practice you're using Vim even when you type vi. For the exam, this distinction barely matters in practice. Learn vim. The core commands work identically whether the system calls it vi or vim.

The Concept That Trips Up Everyone: Modes

This is the single biggest adjustment for anyone coming from a typical text editor. Vim doesn't let you just click and type. It operates in distinct modes, and what your keystrokes do depends entirely on which mode you're in.

  • Normal mode
    • This is where you land when you open a file, and where you return after every edit
    • Keystrokes here are commands, not text. Typing dd deletes a line. Typing x deletes a character. None of this inserts text.
    • Navigation, deleting, copying, and pasting all happen from here
  • Insert mode
    • This is where you actually type text into the file, the way you'd expect any normal editor to work
    • You enter it deliberately with a command like i or a, you don't start here
    • Press Esc to leave insert mode and return to normal mode
  • Command mode
    • Entered by typing : from normal mode
    • Used for saving, quitting, search and replace, and other file-level operations
    • You type a command after the colon and press Enter to run it

The number one beginner mistake: typing text while still in normal mode, which triggers a chaotic sequence of unrelated commands instead of writing anything. If your screen suddenly looks wrong, the first thing to check is which mode you're in.

# Open a file
vim /etc/hosts

# Enter insert mode to start typing
i

# Exit insert mode back to normal mode
Esc

# Enter command mode to save and quit
:wq

Opening, Saving, and Quitting

These are the commands you'll use in literally every single vim task on the exam. Get them automatic before anything else.

# Open a file (creates it if it doesn't exist)
vim /etc/example.conf

# Save changes without quitting
:w

# Save and quit
:wq

# Quit without saving (will warn if there are unsaved changes)
:q

# Force quit without saving, discarding all changes
:q!

# Force save and quit, even if file permissions normally complain
:wq!

Know :q! cold. It's your panic button. If you've made a mess of a file and you're not confident about cleaning it up, quitting without saving and starting over is almost always faster than trying to fix it under pressure.

Navigation: Moving With Intent

Vim navigation is built around the idea that you should never need to hold down an arrow key. Learning to move efficiently is what separates someone who can technically use vim from someone who's actually fast in it.

Basic Movement

h    # move left
j    # move down
k    # move up
l    # move right

0    # jump to the start of the current line
$    # jump to the end of the current line
^    # jump to the first non-blank character of the line

gg   # jump to the first line of the file
G    # jump to the last line of the file
:42  # jump to line 42

Word and Section Movement

w    # jump forward to the start of the next word
b    # jump backward to the start of the previous word
e    # jump to the end of the current/next word

{    # jump back one paragraph or block
}    # jump forward one paragraph or block

A practical habit: combine a number with a movement command to jump multiple steps at once. 5j moves down 5 lines. 3w jumps forward 3 words. This is far faster than repeating a single keystroke.

Editing: Insert, Delete, Copy, and Paste

Entering Insert Mode

i    # insert before the cursor
a    # insert after the cursor (append)
I    # insert at the start of the line
A    # insert at the end of the line
o    # open a new line below and enter insert mode
O    # open a new line above and enter insert mode

Deleting Text

x     # delete the character under the cursor
dd    # delete the current line
3dd   # delete 3 lines starting from the current one
dw    # delete from the cursor to the end of the current word
d$    # delete from the cursor to the end of the line
D     # same as d$, delete to end of line

Copy (Yank) and Paste

Vim calls copying "yanking." This terminology trips up a lot of people coming from other editors, but the logic is consistent once you know it.

yy    # yank (copy) the current line
3yy   # yank 3 lines
yw    # yank from the cursor to the end of the word
p     # paste after the cursor / current line
P     # paste before the cursor / current line

Note that dd doesn't just delete, it also stores what was deleted, so dd followed by p effectively cuts and pastes a line elsewhere in the file.

Undo and Redo

u        # undo the last change
Ctrl+r   # redo (reverse an undo)
U        # undo all recent changes on the current line

Undo in vim can go back many steps in sequence. If you've made a mess, pressing u repeatedly is often safer and faster than trying to manually fix what went wrong.

Search and Replace

This is where vim genuinely outperforms simpler editors, and it's heavily tested because so many LFCS tasks involve finding and changing specific values inside configuration files.

Searching

/pattern    # search forward for "pattern"
?pattern    # search backward for "pattern"
n           # jump to the next match
N           # jump to the previous match (reverse direction)

Search and Replace (Substitution)

# Replace the first match of "old" with "new" on the current line only
:s/old/new/

# Replace all matches of "old" with "new" on the current line
:s/old/new/g

# Replace the first match on every line in the file
:%s/old/new/

# Replace ALL matches on every line in the file (the one you'll use most)
:%s/old/new/g

# Same as above, but ask for confirmation before each replacement
:%s/old/new/gc

Break down what's happening in :%s/old/new/g, since this single command pattern covers most exam-style editing tasks:

  • : enters command mode
  • % means apply this across the whole file, not just the current line
  • s means substitute
  • /old/new/ is the pattern to find and what to replace it with
  • g means replace every match on each line, not just the first one found

This single command is one of the highest-value things to have automatic for the exam. A task that says "change every instance of a specific value in this config file" is exactly this command, every time.

A Typical Exam-Style Editing Task

Open the file /etc/app/config.conf. Find every line containing the word development and replace it with production. Save your changes and exit.

vim /etc/app/config.conf

# Inside vim, in command mode:
:%s/development/production/g
:wq

That's the entire task. The speed comes from not having to think about each piece separately, the whole sequence should come out as one fluid motion by the time you sit the real exam.

Common Mistakes

  • Typing while in normal mode. If letters seem to be doing random things instead of appearing as text, you're not in insert mode. Press Esc, then i, then try again.
  • Forgetting to press Esc before running a command. Commands like :wq only work from normal mode. If command mode isn't responding, you're probably still in insert mode.
  • Using :s instead of :%s and wondering why only one line changed. Without the %, substitution only applies to the current line.
  • Forgetting the trailing g and only replacing the first match per line instead of all of them.
  • Panicking instead of using :q!. If a file is genuinely a mess, quitting without saving and reopening it is usually faster than trying to manually undo your way out.
  • Not saving before testing a service. Editing a config file and forgetting :w before running systemctl restart means you're testing the old, unmodified file.

Quick Reference

  • File operations:
    • :w: save
    • :wq: save and quit
    • :q!: quit without saving
  • Entering insert mode:
    • i: insert before cursor
    • a: insert after cursor
    • o: new line below, insert mode
  • Navigation:
    • 0 / $: start / end of line
    • gg / G: start / end of file
    • :NUMBER: jump to a specific line
  • Editing:
    • dd: delete line
    • yy: copy line
    • p: paste
    • u: undo
  • Search and replace:
    • /pattern: search forward
    • n: next match
    • :%s/old/new/g: replace all matches in the file

Why This Matters Beyond the Exam

  • Required for LFCS specifically: vi/vim usage is a direct exam objective, not an assumed background skill
  • Nearly every task touches a file: service configs, network settings, scripts, cron entries, almost everything in the LFCS task list eventually means opening a file in vim
  • Speed compounds across the exam: a task that should take 2 minutes takes 6 if you're hunting for keys instead of typing on instinct, and that time adds up fast across 17 to 20 tasks in a 2-hour window
  • It's the default everywhere: vi or vim is present on essentially every Linux system you'll ever administer, with or without a GUI

Practice This Properly Before the Exam

Reading a command list doesn't build the muscle memory the LFCS actually tests. The only way to get fast in vim is to use it under realistic conditions, repeatedly, until normal mode, insert mode, and command mode stop requiring conscious thought.

LinuxCert.Guru has a dedicated lab built around exactly this: Text Editing With Vi/Vim. It covers modes, navigation, editing commands, search and replace, and the saving and recovery habits this guide walks through, all practiced hands-on in a real terminal rather than read about in a list.

Practice the Text Editing With Vi/Vim lab at LinuxCert.Guru → https://linuxcert.guru/lfcs/?name=lfcs-text-editing-with-vi

Conclusion

Vi/vim isn't a side skill for LFCS, it's the tool you'll use to complete nearly every task on the exam. The learning curve is real, modes especially trip up almost everyone at first, but the actual command set you need is small and learnable.

  • Know your modes cold: normal, insert, command
  • Make :wq and :q! completely automatic
  • Learn to navigate without arrow keys
  • :%s/old/new/g is the single most valuable command for exam-style editing tasks
  • Practice until none of this requires conscious thought

Speed in vim isn't about memorizing more commands than the next person. It's about the handful of commands above becoming so automatic that editing a file stops being a separate task and just becomes part of the flow of completing whatever you were actually trying to do.

 

$_
Ready to go beyond reading?Practice with free, auto-graded RHCSA labs.
Start free →