Lesson 4. Cursor Tab and Inline Edit — writing code quickly
Tab and Inline Edit are the daily tools of Cursor. Tab suggests continuations for your code. Inline Edit (Cmd+K) allows you to modify selected code. With these two tools, you can work 3-5 times faster.
Topic breakdown
Cursor Tab is not regular autocomplete. Classic autocomplete only suggests variable names. Cursor Tab predicts entire lines, functions, and logical blocks. It understands your project's context, code style, and goal.
Inline Edit (Cmd+K on Mac, Ctrl+K on Windows) enables quick editing of a line or block. Highlight code, press Cmd+K, describe what to do — and the AI applies changes. For example: 'add error handling to this function' or 'optimize this loop'.
Tab and Inline Edit work perfectly together: when writing new code, Tab suggests the continuation, and when editing existing code, Inline Edit is used. You don't need to open Chat or Agent mode — these are rapid tools requiring minimal actions.
Practical tip: to fully accept a Tab suggestion press Tab; for partial accept press Cmd+→ (word by word). If the suggestion is wrong, just keep typing, and the AI will offer a new one.
What you'll learn
- Understand how Tab completion works and use it effectively
- Edit existing code using Inline Edit (Cmd+K / Ctrl+K)
- Master the partial accept technique
- Distinguish when to use Tab and when to use Inline Edit
- Memorize essential keyboard shortcuts
Deep dive
How Tab completion works technically: Cursor sends your cursor position, the surrounding code (50-100 lines above and below), open files, and project structure to the AI model. In 100-200ms, the model returns the most probable continuation. As you type, the suggestion updates. This is real-time prediction — you don't even have to ask.
The power of Inline Edit lies in modifying only the selected code without touching the rest of the file. This distinguishes it from Chat — Chat might rewrite the whole file, while Inline Edit acts like surgery: exactly where needed. For example: adding error handling to one function, renaming a variable, or optimizing one loop.
Pro-technique — Multi-cursor Tab: By placing multiple cursors (Alt+Click), you can get a Tab suggestion for each one. This is very useful when writing repetitive code — like multiple similar functions or tests.
Partial accept strategy: Sometimes a Tab suggestion starts right but ends wrong. In this case, press Cmd+→ to accept only the first word or part, then press Tab again — a new suggestion will appear. This is called 'progressive accept', and experienced users always work this way.
Ready prompt template
Copy and adaptThis function checks the user's age. Please: 1) add input validation (check if it's a number), 2) for values less than 0 and greater than 150 return an error, 3) add TypeScript types.
Why it works
Context: 'This function' — Inline Edit works with the selected code
Clear task list: 1, 2, 3 — AI executes each sequentially
Technical requirement: 'input validation', 'return an error' — specific functionality
Language requirement: 'TypeScript types' — AI converts JavaScript to TypeScript
Practice
- Create a new file in Cursor: utils.ts
- Type 'export function ' and wait for a Tab suggestion — accept it
- Create a simple function: 'function greet(name) { return "Hello " + name }'
- Highlight the function, press Cmd+K and type 'Add TypeScript types and use template literals'
- Review the result and click Accept/Reject
- Start a new line and type 'function calculate' — try the Tab suggestion
Common mistakes
- Blindly accepting every Tab suggestion — only accept if it's logical, otherwise keep typing
- Highlighting too large a block for Inline Edit — 5-20 lines is optimal; for 100+ lines, Chat is better
- Forgetting the shortcut — Cmd+K is the most used, memorize it
- Accepting the Inline Edit result without viewing the diff — always review changes
Lesson FAQ
How can I improve Tab completion quality?
Use descriptive names (for variables, functions), write comments, and organize your files logically. Cursor learns from context — clean code = good suggestions.
How many lines can Inline Edit modify?
There is no technical limit, but 5-30 lines is optimal. For larger blocks (50+ lines), it's better to use Chat mode, as it handles a broader context.
Can I turn off Tab suggestions?
Yes, in Settings > Cursor Tab, you can toggle 'Enable' off, or disable it for specific file types. However, this is not recommended, as Tab is fundamental to vibe coding.