Vim fundamentals
You learn modes, movement, editing, searching and saving in Vim, which is on every server, and edit config files without fear.
Level 101 · 19 lessons · 18 practice labs
Lessons
Modes and survival
- Why Vim: an editor ready on every server
- Modes: normal, insert and command mode
- Opening, saving and quitting: :w, :q, :wq, :q!
- Practising on your own with vimtutor
- Short task: change one line of a config file and save
Moving around
- Moving by character, word and line
- Jumping to a line and to the start or end of a file
- Searching: /, ?, n and N
- Short task: find a setting in a long file and fix it
Editing
- Deleting and changing: d, c, x and counts
- Copying and pasting: y and p
- Undo, redo and the dot command
- Selecting in visual mode
- Find and replace with :s
- Short task: clean old entries out of a hosts file
Working comfortably
- Line numbers, syntax colours and temporary settings
- Editing a privileged file safely: sudoedit
- The swap file warning and recovering a crashed session
- Capstone: repair a broken service config using only Vim
Practice labs
- Change one line in Vim and save: Change the listening port in the service config to the requested value in Vim, then save and quit.
- Quit without saving a bad edit: Quit the accidentally mangled hosts file without saving, then add the right line and save.
- Save a file opened read-only, safely: Write your change from a config opened without rights to a separate file, then apply it to the real file with sudoedit.
- Jump straight to the line in the error: Jump straight to the line number reported by the syntax error in Vim and add the missing character.
- Find a setting in a long file and fix it: Search a config of thousands of lines with / to find a commented-out setting, uncomment it and fix its value.
- Review every place a value appears: Step through every line containing the old server name with n and N and change it only on active lines.
- Delete old entries with counts: Remove the consecutive lines for the old network from the hosts file using counted delete commands.
- Repeat a fix with the dot command: Add the missing semicolon to the end of one entry and repeat it on the other lines with the dot command.
- Fix broken indentation in visual mode: Select a wrongly indented block in a YAML file in visual mode, shift it to the right level and make the file valid.
- Undo the wrong changes: Undo only the last two of several edits, keep the first and save the file.
- Bring back a wrongly saved file from its backup copy: Compare a config overwritten by mistake with the backup copy Vim left behind, restore only the damaged section and save.
- Go back to an earlier state in undo history: In a config with persistent undo enabled, travel back by time to the working state of ten minutes ago and save the file in that state.
- Replace an old domain across the file: Replace every occurrence of the old domain in the config with the new one using :s.
- Apply a change to one section only: Change the timeout values only within one section's line range with :s, leaving other sections untouched.
- Update only the right lines with confirmed replace: In a file where a word appears on both active and comment lines, update only the active ones with :s///gc.
- Recover a crashed session from the swap file: Recover unsaved edits lost when the connection dropped from the swap file, save them and clean up the swap file.
- Spot the error with numbers and syntax colours: Turn on line numbers and syntax colours to find the unclosed quote and fix it.
- Repair a broken service config using only Vim: Find and fix the three errors in the failing service's config using only Vim so the service passes its check.
About this course
You learn modes, movement, editing, searching and saving in Vim, which is on every server, and edit config files without fear.
What you will learn
- Modes and survival
- Moving around
- Editing
- Working comfortably
Prerequisites
No prior knowledge is needed; the course starts from zero.
Lab environment
Lessons run in your own Kali Linux terminal that opens in the browser. Nothing to install; the lab starts clean in every lesson.
Frequently asked questions
- Is this course right for my level?
- The course is at beginner level; every term is explained where it first appears.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.