Learn Lua in Neovim: Iterating Tables — pairs, ipairs, Gap Behavior & Word Counter | Episode 20
15views
0011:56
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Two loops, two purposes. In this episode we cover ipairs for ordered array iteration, pairs for visiting every key in a table,
how gaps break ipairs, and we build a word frequency counter to put pairs to practical use.
Every keystroke is shown on screen with 3-second pauses so you can follow along at your own pace.
What You'll Learn:
- ipairs(t) — iterate array elements in order (1, 2, 3...)
- pairs(t) — iterate all keys in any order
- Gap behavior — ipairs stops at the first nil hole
- When to use ipairs vs pairs
- Building a word frequency counter with pairs
Neovim Commands Used:
- F( — find character backward (open paren)
- b — move back one word
- cw — change word (fix ipairs → pairs)
- /for — search forward for "for"
- n — jump to next search match
Timestamps:
0:00 Intro
0:12 Preview
0:44 Open file
1:28 ipairs — Array iteration
2:18 Run ipairs demo
3:03 pairs — Dictionary iteration
4:27 Fix ipairs → pairs (F( b cw)
4:51 Run pairs demo
5:31 ipairs gap behavior
6:38 Run gap demo
7:16 Word frequency counter
9:55 Run final program
10:05 Review — /for search
10:50 Recap
11:22 Next: Nested Tables
Practice code: https://github.com/GoCelesteAI/learn-lua-in-neovim
This is Episode 20 of the Learn Lua in Neovim series. New episodes cover nested tables, references, libraries, and more — all
coded inside Neovim.
Taught by CelesteAI. Like & subscribe for more tutorials!
#lua #neovim #programming #tutorial #beginners #learnlua #luaprogramming #neovimtutorial #luapairs #luaipairs #coding
Tags
lua, lua tutorial, learn lua, lua pairs, lua ipairs, lua iterating tables, lua table iteration, lua for loop, lua gap behavior,
lua word counter, lua frequency counter, lua pairs vs ipairs, lua for beginners, neovim lua, neovim tutorial, learn lua in
neovim, lua episode 20, programming tutorial, coding tutorial, beginner programming, lua 2026, neovim 2026, screenkey, code
along, lua basics, lua data structures
Tags
lualua tutoriallearn lualua pairslua ipairslua iterating tableslua table iterationlua for looplua gap behaviorlua word counterlua frequency counterlua pairs vs ipairslua for beginnersneovim luaneovim tutorial