Nvim Session 03: Line & Character Motions
Line-wise precision: jump to line start, end, first character. Character search: find any character instantly with f and t.
Pre-Session State
-
Comfortable with
w W b Bmotions -
Understand operator + motion
-
Know line position commands
-
Know character search commands
Lesson 1: Line Position Motions
Concept: Navigate within a line without searching.
Exercise 1.1: Line boundaries
Create this test line:
server_hostname = "vault-01.inside.domusdigitalis.dev"
0 " Column 0 (first position, the space)
^ " First non-blank character (s in server)
$ " End of line (last ")
g_ " Last non-blank character (same as $ here)
Exercise 1.2: When g_ differs from $
Line with trailing spaces:
config_value = "something"
^ trailing spaces
$ " Moves to last space
g_ " Moves to last " (non-blank)
Use case: dg_ deletes content, d$ deletes trailing whitespace too.
Exercise 1.3: Combining with operators
hostname: vault-01.inside.domusdigitalis.dev
|cursor here
d0 " Delete to line start (leaves indentation gap)
d^ " Delete to first non-blank
D " Same as d$ (delete to end)
C " Same as c$ (change to end)
Exercise 1.4: Column positioning
| " Column 1 (same as 0)
20| " Column 20
80| " Column 80 (useful for line length check)
gm " Middle of screen line
Lesson 2: Character Search - f and t
Concept: Jump directly to any character on the line.
Exercise 2.1: Forward find with f
server_hostname = "vault-01.inside.domusdigitalis.dev" |
f= " Jump TO = (inclusive)
f" " Jump TO first "
f. " Jump TO first .
fv " Jump TO v in vault
Inclusive: Cursor lands ON the character.
Exercise 2.2: Forward until with t
server_hostname = "vault-01.inside.domusdigitalis.dev" |
t= " Jump UNTIL = (cursor before =)
t" " Jump UNTIL " (cursor before ")
Exclusive: Cursor lands BEFORE the character.
Exercise 2.3: Backward search with F and T
server_hostname = "vault-01.inside.domusdigitalis.dev"
|
F" " Backward TO "
F= " Backward TO =
T. " Backward UNTIL .
Exercise 2.4: Repeat with ; and ,
After any f/F/t/T:
; " Repeat same direction
, " Repeat opposite direction
Example:
one.two.three.four.five |
f. " Jump to first .
; " Next . (between two/three)
; " Next . (between three/four)
, " Previous . (back)
Lesson 3: f/t + Operators
Concept: Character search becomes a motion for operators.
Exercise 3.1: Delete to character
hostname: vault-01.inside.domusdigitalis.dev |
dt: " Delete UNTIL colon → : vault-01...
df: " Delete through colon (inclusive) → vault-01...
Exercise 3.2: Change to character
config["database"]["hostname"]
|
ct] " Change until ] → config[]
cf" " Change through " → config[database"]["hostname"]
Exercise 3.3: Delete between characters
"this is a quoted string" |
dt" " Delete until closing quote → ""
But better:
di" " Delete inside quotes (text object, Session 08)
Lesson 4: Practical Patterns
Exercise 4.1: YAML key-value editing
hostname: old-value.domain.com |
f:w " Jump to colon, word forward → on old-value
ct. " Change until first . → hostname: |.domain.com
Or:
f:lcW " Colon, right, change WORD
Exercise 4.2: URL editing
https://github.com/user/repo/blob/main/file.txt |
Jump to specific parts:
f/;; " First /, repeat twice → at /user
f/;;; " Three more → at /blob
t. " Until . → just before .txt
Exercise 4.3: Log line parsing
2026-03-18 14:30:22 ERROR [module] Connection failed: timeout |
2f: " Jump to second : (time separator)
f[ " Jump to [
ci[ " Change inside brackets
f]w " Jump past ], to next word
Exercise 4.4: IP address navigation
address: 10.50.1.120
|
f. " First octet boundary
; " Second boundary
; " Third boundary
ct<CR> " Change until end
Lesson 5: Advanced Line Motions
Exercise 5.1: Line navigation across wraps
With long lines that wrap on screen:
gj " Down within wrapped line (visual)
gk " Up within wrapped line
g0 " Start of screen line
g$ " End of screen line
g^ " First non-blank of screen line
Exercise 5.2: Vertical line motions
+ " First non-blank of next line
- " First non-blank of previous line
_ " First non-blank of current line (like ^)
With counts:
5+ " Down 5 lines, first non-blank
3- " Up 3 lines, first non-blank
Exercise 5.3: Go to specific column
40| " Go to column 40
:set colorcolumn=80 " Show column marker
80| " Check if line exceeds 80 chars
Summary: Line & Character Reference
| Motion | Effect |
|---|---|
|
Column 0 (line start) |
|
First non-blank |
|
Line end |
|
Last non-blank |
|
Column 1 (with count: n|) |
|
Forward TO character |
|
Backward TO character |
|
Forward UNTIL character |
|
Backward UNTIL character |
|
Repeat f/F/t/T same direction |
|
Repeat f/F/t/T opposite direction |
The f/t Decision
Use f |
Use t |
|---|---|
When you want the character |
When deleting/changing UP TO it |
|
|
|
|
Exercises to Complete
-
[ ] Use
0 ^ $ g_on lines with varying whitespace -
[ ] Practice
fto jump to specific characters -
[ ] Delete with
dtanddf- feel the difference -
[ ] Chain
fwith;to navigate repeated characters -
[ ] Edit a YAML file using
f:patterns
Next Session
Session 04: Search Motions - Pattern search with /, ?, *, #.
Session Log
| Timestamp | Notes |
|---|---|
Start |
<Record when you started> |
End |
<Record when you finished> |
Discoveries |
<What surprised you?> |