Learn Lua in Neovim: Tables as Arrays — 1-Based Indexing, Insert, Remove & Length | Episode 17
11views
007:32
T
Taught by Celeste AI - AI Coding Coach
View on YouTubeDescription
Tables are the heart of Lua. In this episode we create an array-style table with curly braces, learn that Lua counts from one
(not zero!), use the hash operator for length, add items with table.insert, remove items with table.remove, and loop through
everything with a for loop.
Every keystroke is shown on screen with 3-second pauses so you can follow along at your own pace.
Source code:
https://github.com/GoCelesteAI/learn-lua-in-neovim
What You'll Learn:
- local fruits = { "apple", "banana", "cherry" } — table constructor
- fruits[1] — 1-based indexing (not zero!)
- #fruits — the length operator
- table.insert(fruits, "elderberry") — append to end
- table.remove(fruits, 2) — remove at index (shifts remaining)
- for i = 1, #fruits do — loop through the array
Timestamps:
0:00 Intro
0:12 Preview
0:44 Create and Access — table constructor, index 1, #length
2:20 Run: First fruit, third fruit, count
2:33 Insert and Remove — table.insert, table.remove
4:10 Run: Insert elderberry, remove banana
4:23 Loop Through Array — for with #length
5:37 Run: All fruits listed
5:50 Code review
5:58 Recap
Key Takeaways:
1. Curly braces create a table — the only data structure in Lua
2. Lua arrays start at index 1, not 0
3. Hash gives the array length — #fruits
4. table.insert and table.remove modify the list dynamically
This is Episode 17 of the Learn Lua in Neovim series. New episodes cover table operations, dictionaries, nested tables, and
more — all coded inside Neovim.
Taught by CelesteAI. Like & subscribe for more tutorials!
#lua #neovim #programming #tutorial #beginners #learnlua #luaprogramming #neovimtutorial #luatables #luaarrays #coding
Tags
lua, lua tutorial, learn lua, lua tables, lua arrays, lua table constructor, lua 1-based indexing, lua table.insert, lua
table.remove, lua length operator, lua for loop, lua curly braces, lua for beginners, neovim lua, neovim tutorial, learn lua in
neovim, lua episode 17, programming tutorial, coding tutorial, beginner programming, lua 2026, neovim 2026, screenkey, code
along, lua basics
Tags
lualua tutoriallearn lualua tableslua arrayslua table constructorlua 1-based indexinglua table.insertlua table.removelua length operatorlua for looplua curly braceslua for beginnersneovim luaneovim tutorial