LEARN VIM MOTIONS
Learn Vi Motions: The Language of Text Editing
Goal: Wired your brain to speak the “grammar” of Vim. Stop editing character-by-character and start editing by word, sentence, block, and logic.
The Philosophy: It’s a Language, Not a Tool
Most editors treat text as a long string of characters. Vi/Vim treats text as structured objects.
To master “Raw Vi,” you must stop thinking “Move cursor right 5 times, backspace 3 times, type word.”
Instead, you must think: “Change inside quotes” (ci") or “Delete until next comma” (dt,).
You are learning a language where:
- Verbs (Operators):
d(delete),c(change),y(yank/copy),v(visual select). - Nouns (Motions/Objects):
w(word),s(sentence),p(paragraph),}(block),i((inside parenthesis). - Adjectives (Counts):
3w(3 words),5j(5 lines down).
The Grammar: Verb + Count + Noun.
Core Concept Analysis
1. Navigation vs. Operation
- Navigation: Getting from A to B (
hjkl,w,b,f,/,G). - Operation: Doing something to the text between A and B (
d,c,y,>).
2. Text Objects (The “Inside” Job)
- Instead of moving over text, you act on a defined area.
iw(Inner Word),it(Inner Tag),i"(Inner Quotes).
3. The Dot Command (.)
- The single most powerful feature in Vi. It repeats the last change.
- If you structure your edits correctly (One motion + One change), the
.key becomes a machine gun of productivity.
Project List
These projects are designed to break your reliance on the mouse and arrow keys. They force you to use specific families of motions to survive.
Project 1: The “No-HJKL” Navigator
- File: LEARN_VIM_MOTIONS.md
- Main Programming Language: Text (Any large source file)
- Alternative Programming Languages: N/A
- Coolness Level: Level 2: Practical but Forgettable
- Business Potential: 1. The “Resume Gold” (Efficiency)
- Difficulty: Level 1: Beginner
- Knowledge Area: Horizontal/Vertical Navigation
- Software or Tool: Vim / Neovim (No plugins)
- Main Book: Practical Vim by Drew Neil (Chapter 1)
What you’ll build: You will take a large file (e.g., a minified jQuery file or a large log file) and navigate to specific targets using only advanced motions. You are forbidden from using h, j, k, l (and definitely no arrow keys).
Why it teaches [Vi Motions]: Beginners get stuck spamming l to move right. This forces you to use w (word), e (end of word), f (find char), and t (til char).
Core challenges you’ll face:
- Precision Jumping: Landing exactly on a semicolon using
f;. - Long Distance Travel: Moving by paragraphs
}or percentage%instead of scrolling. - Screen positioning: Using
H(High),M(Middle),L(Low) to jump screen sections.
Key Concepts:
- Character Search:
:h f - Word Motion:
:h word - Screen Motion:
:h H
Difficulty: Beginner Time estimate: Weekend Pre-requirements: Disable arrow keys in your config.
Real world outcome:
- You will be able to look at a character on the screen and jump to it in 2 keystrokes, rather than holding down a key for 3 seconds.
Implementation Hints: Open a file. Pick a word on line 50. Try to get there in under 4 keystrokes.
- Hint 1:
50G(Go to line 50). - Hint 2:
f{char}(Jump to specific character). - Hint 3:
;(Repeat the jump).
Project 2: The JSON Surgeon (Text Objects)
- File: LEARN_VIM_MOTIONS.md
- Main Programming Language: JSON
- Alternative Programming Languages: HTML, XML
- Coolness Level: Level 3: Genuinely Clever
- Business Potential: 1. The “Resume Gold”
- Difficulty: Level 2: Intermediate
- Knowledge Area: Text Objects / Selection
- Software or Tool: Vim
- Main Book: Practical Vim (Chapter 8: Navigate and Operate)
What you’ll build: A cleaned-up configuration file. You will take a deeply nested, messy JSON file and rearrange keys, delete entire blocks, and change values using Text Objects.
Why it teaches [Vi Motions]: You will learn that you don’t need to highlight text manually. You will learn to “Delete inside braces” or “Change inside quotes.”
Core challenges you’ll face:
- Selecting structure, not lines: Deleting a whole object with
da{. - Changing values: Changing a key’s value with
ci". - Navigating Brackets: Jumping between matching braces with
%.
Key Concepts:
- Inner vs Around:
i(inner) vsa(around/all). - Block Objects:
di{,da[,di(.
Difficulty: Intermediate Time estimate: Weekend Pre-requirements: Project 1
Real world outcome:
- A perfectly formatted JSON file created without ever manually highlighting a character. You will feel the power of “Noun-Verb” editing.
Implementation Hints:
- To change a value: Place cursor inside quotes, type
ci", type new text, hit Esc. - To delete a whole block: Place cursor inside
{...}, typeda{. - To copy a whole block:
ya{.
Project 3: The Code Refactor (Change Operator)
- File: LEARN_VIM_MOTIONS.md
- Main Programming Language: Python (or C/JavaScript)
- Alternative Programming Languages: Any verbose language
- Coolness Level: Level 2: Practical
- Business Potential: 1. The “Resume Gold”
- Difficulty: Level 2: Intermediate
- Knowledge Area: Operators / Dot Command
- Software or Tool: Vim
- Main Book: Practical Vim (Chapter 2: The Dot Command)
What you’ll build: You will take a Python script with poor variable names (e.g., x, y, data) and legacy formatting, and refactor it into clean, descriptive code using the . (dot) command.
Why it teaches [Vi Motions]: This teaches the “Edit-Repeat” paradigm. instead of doing the same edit 10 times, you do it once perfectly, and repeat it 9 times with one key.
Core challenges you’ll face:
- Search and Next: Using
*to search for the word under cursor andnto go to the next one. - Repeatable Edits: Using
cw(change word) instead of backspacing, so the dot command knows what to repeat. - Contextual Jumping: Using
%to jump between if/else blocks.
Key Concepts:
- The Dot Command:
:h . - Search Navigation:
:h * - Change Operator:
:h c
Difficulty: Intermediate Time estimate: Weekend Pre-requirements: Basic Python/C syntax knowledge.
Real world outcome:
- Refactoring a variable name across a file in seconds without using “Find and Replace” tools, giving you granular control over every change.
Project 4: The Markdown Re-Sequencer (Line Operations)
- File: LEARN_VIM_MOTIONS.md
- Main Programming Language: Markdown
- Alternative Programming Languages: LaTeX
- Coolness Level: Level 2: Practical
- Business Potential: 2. Micro-SaaS (Writing/Blogging)
- Difficulty: Level 1: Beginner
- Knowledge Area: Line Motions / Visual Block
- Software or Tool: Vim
- Main Book: Modern Vim
What you’ll build: A structured blog post or README. You will start with a dump of disordered paragraphs and lists, and you must reorder them, format headers, and create checklists.
Why it teaches [Vi Motions]: This focuses on “Line” objects. Moving whole lines, deleting whole lines, and formatting blocks of text.
Core challenges you’ll face:
- Moving Lines:
dd(delete) andp(put) to move paragraphs. - Visual Block Mode: Adding
- [ ]to 10 lines at once usingCtrl+v. - Sentence Navigation: Using
(and)to move by sentence. - Paragraph Navigation: Using
{and}.
Key Concepts:
- Visual Block:
:h ctrl-v - Put/Paste:
:h p - Sentence/Paragraph Motion:
:h sentence
Difficulty: Beginner Time estimate: Weekend Pre-requirements: None.
Real world outcome:
- You will be able to turn a raw list of items into a TODO list in 3 keystrokes using Visual Block mode.
Project 5: The Log Parser (Macros)
- File: LEARN_VIM_MOTIONS.md
- Main Programming Language: Raw Log Data
- Alternative Programming Languages: CSV
- Coolness Level: Level 3: Genuinely Clever
- Business Potential: 3. Service & Support (Data Analysis)
- Difficulty: Level 3: Advanced
- Knowledge Area: Macros / Complex Motions
- Software or Tool: Vim
- Main Book: Practical Vim (Chapter 11: Macros)
What you’ll build: A clean CSV file derived from a messy server log. The log has inconsistent spacing, timestamps in brackets, and IP addresses. You will record a macro to clean one line, and play it back on 1000 lines.
Why it teaches [Vi Motions]: Macros force you to be precise. If your motion is “move right 5 times,” it will break on the next line. If your motion is “find next bracket” (f]), it will work everywhere.
Core challenges you’ll face:
- Relative Line Numbers: Calculating how many times to run the macro.
- Atomic Motions: Creating a sequence of edits that works regardless of line length.
- Macro Recording:
qa(record to register a),q(stop),@a(play).
Key Concepts:
- Registers:
:h registers - Macros:
:h complex-repeat - Pattern Searching:
/
Difficulty: Advanced Time estimate: 1 week Pre-requirements: Projects 1-3.
Real world outcome:
- Converting 500 lines of messy data into a spreadsheet-ready format in under 10 seconds.
Project 6: The HTML Tag Wrapper (Surround Simulation)
- File: LEARN_VIM_MOTIONS.md
- Main Programming Language: HTML
- Alternative Programming Languages: JSX / XML
- Coolness Level: Level 3: Genuinely Clever
- Difficulty: Level 3: Advanced
- Knowledge Area: Registers / Marks
- Main Book: Practical Vim
What you’ll build: An HTML structure where you need to wrap existing text in <div> tags, change <h1> to <h3>, and move attributes around. Crucially, you cannot use the vim-surround plugin.
Why it teaches [Vi Motions]: Plugins like vim-surround are great, but implementing them manually teaches you about Marks and Registers.
Core challenges you’ll face:
- Marks: Setting a mark
maat the start of a word, moving to the end, and jumping back. - Insert Normal Mode:
Ctrl+oin insert mode to do one normal command. - Tag Blocks: Using
vit(visual inner tag) andcat(change around tag).
Key Concepts:
- Marks:
:h m(set mark),:h '(jump to mark). - Tag Objects:
it,at.
Real world outcome:
- You will understand how plugins actually work under the hood, and you’ll be comfortable navigating XML structures.
Project 7: The “Vim Golf” Challenge
- File: LEARN_VIM_MOTIONS.md
- Main Programming Language: Text
- Coolness Level: Level 4: Hardcore Tech Flex
- Difficulty: Level 4: Expert
- Knowledge Area: Optimization
- Software or Tool: vimgolf.com (or local simulation)
What you’ll build: You aren’t building a file; you are building efficiency. You will take a “Before” file and an “After” file, and try to transform one to the other in the fewest keystrokes possible.
Why it teaches [Vi Motions]: This forces you to learn obscure but powerful motions like ~ (toggle case), gU (uppercase), xp (swap chars), and dt (delete til).
Core challenges you’ll face:
- Keystroke Economy: Why press
ddwhenDdoes the job? - Lateral Thinking: Solving editing problems like a puzzle.
Real world outcome:
- You will look like a wizard to anyone watching your screen.
Project 8: The Config Builder (Vanilla Vimrc)
- File: LEARN_VIM_MOTIONS.md
- Main Programming Language: VimScript
- Coolness Level: Level 4: Hardcore Tech Flex
- Difficulty: Level 3: Advanced
- Knowledge Area: Vim Configuration
- Software or Tool: Vim
What you’ll build: A .vimrc file from scratch that enables only the essential features for raw motion efficiency (like relative numbers and search highlighting).
Why it teaches [Vi Motions]: You need to understand how Vim “sees” lines and searches to configure it. Setting relativenumber changes how you use j and k.
Core challenges you’ll face:
- Relative Numbers: Understanding why seeing “10” lines up is better than seeing line “453”.
- Key Mapping: Creating a Leader key to make common motions faster.
Key Concepts:
set relativenumbernnoremap
Real world outcome:
- A portable, powerful Vim environment you can deploy on any server in the world.
Project 9: The Code Navigator (CTags & Jumps)
- File: LEARN_VIM_MOTIONS.md
- Main Programming Language: C or Go (Large codebase)
- Difficulty: Level 3: Advanced
- Knowledge Area: Jumping / Tag Stack
What you’ll build: You will clone a medium-sized open source repo (like Redis) and navigate the call stack to understand a specific function implementation without a file tree (NERDTree).
Why it teaches [Vi Motions]: Vim has a “Jump List”. Every time you make a major move (search, go to line, go to definition), it saves a breadcrumb.
Core challenges you’ll face:
- The Jump List:
Ctrl+o(Old jump) andCtrl+i(New jump). - Go to Definition:
gd(local) andCtrl+](tags). - Method Navigation:
[mand]m(start/end of method - language dependent).
Real world outcome:
- Navigating a 10,000 line codebase faster than someone using VS Code’s mouse-driven “Go to Definition.”
Project 10: The Search-Replace Master (Substitutions)
- File: LEARN_VIM_MOTIONS.md
- Main Programming Language: Regex / Vim Command Line
- Difficulty: Level 4: Expert
- Knowledge Area: Ex Commands / Regex
What you’ll build: A complex transformation script. You will take a text file containing a list of full names and emails, and transform it into a SQL insert statement using only the Command Line mode (:%s).
Why it teaches [Vi Motions]: While not strictly “cursor motion,” understanding the Global command (:g) and Substitution (:s) is part of the “Raw Vim” movement philosophy.
Core challenges you’ll face:
- Capture Groups:
\(\)to save text and\1to paste it. - Global Command:
:g/pattern/dto delete matching lines. - Ranges: Applying changes only to lines 10-20 (
:10,20s/...).
Real world outcome:
- The ability to refactor text patterns that are impossible to do by hand.
Project Comparison Table
| Project | Difficulty | Time | Depth of Understanding | Fun Factor |
|---|---|---|---|---|
| 1. No-HJKL Navigator | Beginner | Weekend | ⭐⭐⭐ | ⭐⭐ |
| 2. JSON Surgeon | Intermediate | Weekend | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| 3. Code Refactor | Intermediate | Weekend | ⭐⭐⭐⭐ | ⭐⭐⭐ |
| 4. Markdown Sequencer | Beginner | Weekend | ⭐⭐ | ⭐⭐⭐ |
| 5. Log Parser | Advanced | 1 Week | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| 6. HTML Wrapper | Advanced | Weekend | ⭐⭐⭐ | ⭐⭐ |
| 7. Vim Golf | Expert | Ongoing | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| 8. Config Builder | Intermediate | Weekend | ⭐⭐⭐ | ⭐⭐⭐ |
| 9. Code Navigator | Advanced | 1 Week | ⭐⭐⭐⭐ | ⭐⭐⭐ |
| 10. Search-Replace | Expert | Weekend | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
Recommendation
Start with Project 2: The JSON Surgeon.
It gives you the biggest “bang for your buck.” Learning Text Objects (ci", da{) immediately makes you feel faster than a normal editor. It’s the “Magic” moment of Vim.
Then move to Project 1: No-HJKL.
Once you can manipulate objects, learn to fly to them efficiently using f, t, and /.
Finally, Project 5: Log Parser.
This brings everything together (navigation + operation) into a repeatable macro.
Summary: All Projects
| # | Project Name | Main Skill |
|---|---|---|
| 1 | The “No-HJKL” Navigator | Horizontal/Vertical Jumps |
| 2 | The JSON Surgeon | Text Objects |
| 3 | The Code Refactor | Change Operator / Dot Command |
| 4 | The Markdown Re-Sequencer | Visual Block / Line Moving |
| 5 | The Log Parser | Macros / Registers |
| 6 | The HTML Tag Wrapper | Marks / Complex Editing |
| 7 | The “Vim Golf” Challenge | Efficiency / Optimization |
| 8 | The Config Builder | Understanding Vim Environment |
| 9 | The Code Navigator | Jump List / Tag Stack |
| 10 | The Search-Replace Master | Regex / Ex Commands |
Essential Resources
Built-in (The Best Resources)
:vimtutor- Run this in your terminal. It is the best tutorial, period.:h motion.txt- The manual on motions.:h operator- The manual on operators.:h text-objects- The manual on noun-selection.
Books
- Practical Vim by Drew Neil. (This is the bible of efficient editing).
- Modern Vim by Drew Neil.
Games
- Vim Adventures: A Zelda-like game played with Vim keys.
- VimGolf: Competitive text editing.
Implementation Hints (Cheatsheet)
- Verb:
d(delete),c(change),y(copy),v(select). - Noun:
w(word),s(sentence),p(paragraph). - Object:
i(inner),a(around). - Target:
t(til),f(find),/(search).
The Golden Rule: If you press a key more than 3 times in a row (e.g., jjj), you are doing it wrong. Find a better motion.