6.2 Multi-line Input
Course: Claude Code - Power User Section: Advanced Input & Interaction Video Length: 2-5 minutes Presenter: Daniel Treasure
Opening Hook
Multi-line input transforms how you work with Claude Code—format code blocks, preserve indentation, paste long context seamlessly. It's the difference between cramped one-liners and clear, readable prompts.
Key Talking Points
1. Why Multi-line Input Matters
- Avoids cramped, unreadable prompts squeezed into one line
- Preserves code formatting, indentation, and structure
- Improves clarity when sharing context, logs, or code samples
- Makes complex requests easier to parse (for you and Claude)
- Essential for pasting multi-line code blocks or config files
What to say: "One of the biggest mistakes I see is trying to cram a whole code block into a single line. It's unreadable, easy to mess up, and Claude has to work harder to understand it. Multi-line input lets you keep things clean."
What to show on screen: Show a cramped one-liner prompt vs. a well-formatted multi-line version side-by-side
2. Methods for Multi-line Input
- Keyboard shortcut: Shift+Enter to add a new line (VS Code style)
- Direct paste: Copy-paste multi-line text; Claude auto-detects and preserves it
- Backslash escape: Use
\at end of line to continue to next line in terminal - Editor-style modes: Some setups support full editor panes for longer inputs
What to say: "If you're in the UI, Shift+Enter is your friend. If you're in the terminal, backslash continuation works. And if you've got code to share, just paste it—Claude figures it out automatically."
What to show on screen: Demo typing in prompt box, press Shift+Enter, show new line appears. Then demo pasting a multi-line code block.
3. Escaping Special Characters
- Shell variables (e.g.,
$VAR) need escaping or quoting - Line breaks are preserved in multi-line input
- Quotes, backticks, and special symbols: context-dependent
- In terminal: use quotes or backslashes
- In UI: usually handled automatically
What to say: "If you're pasting code with shell variables or special characters, wrap it in quotes or be explicit about escaping. Claude will handle it, but being clear prevents confusion."
What to show on screen: Show an example of pasting a shell script with variables, explain the auto-handling. Then show a terminal example with backslash escaping.
4. Best Practices for Clean Multi-line Input
- Use descriptive headers (e.g., "Here's the current code:")
- Separate code blocks from explanation
- Number or label complex requests
- Use code fences or indentation to mark code
- Keep context organized and scannable
What to say: "Structure matters. If you're giving Claude code, logs, and a problem statement, separate them clearly. Use labels. Make it scannable. That's the whole point of multi-line—readability."
What to show on screen: Show a well-structured multi-line prompt with clear sections, then show how Claude responds more accurately to organized input
Demo Plan
- Setup (0:15) — Open Claude Code interface or terminal, show the prompt input area
- Single-line Problem (0:30) — Type a cramped, hard-to-read one-liner with code, show how messy it looks
- Introduce Shift+Enter (1:00) — Clear that, type a simpler version, press Shift+Enter to show new line, keep typing
- Paste Multi-line Code (1:30) — Copy a real code block (e.g., a function), paste it into the prompt, show formatting is preserved
- Show Escaping Example (2:15) — Paste code with shell variables, explain escaping, show Claude handles it
- Structured Prompt Example (2:45) — Build a full prompt with code + context + question, all multi-line and organized
- Submit and Compare (3:30) — Send the prompt, show how Claude's response is better because input was clear
- Wrap-up (4:00) — Emphasize that multi-line input = better results
Code Examples & Commands
Terminal: Backslash continuation
claude code "I need help with this function: \
def process_data(items): \
result = [] \
for item in items: \
result.append(item * 2) \
return result"
Terminal: Quoted multi-line string
claude code "
Here's my code:
def process_data(items):
result = []
for item in items:
result.append(item * 2)
return result
How do I optimize this?
"
UI: Prompt with code block (Shift+Enter for newlines)
Here's my current implementation:
```python
def fetch_user_data(user_id):
# Current approach
connection = open_db()
result = connection.query(f"SELECT * FROM users WHERE id = {user_id}")
connection.close()
return result
What are the issues with this code?
**Escaping in terminal (variables)**
```bash
claude code "
My environment has these variables:
DATABASE_URL=$DATABASE_URL
API_KEY=$API_KEY
How should I use these securely?
"
Gotchas & Tips
-
Shift+Enter only in supported environments — Works in Claude Code UI and some editors. In plain terminal, use backslash (
\) or quotes instead. -
Pasted formatting depends on source — Copy from a code editor = good formatting preserved. Copy from a web page or screenshot = may lose indentation. Verify it looks right.
-
Special characters in terminal need care — Dollar signs, backticks, and quotes have special meaning in bash. Wrap in single quotes if unsure, or use backslash escaping.
-
Blank lines matter — Multi-line input can include blank lines for structure. Use them to separate sections (code block from question, for example).
-
Very long input might hit limits — Extremely large code files or logs might hit token limits. If that happens, trim to the relevant parts and summarize the rest.
-
Indentation is preserved — If you paste indented code, it stays indented. This is usually what you want, but watch for unexpected spacing.
-
Line breaks in the middle of logic — Don't break lines in the middle of a statement unless you're using explicit continuation (backslash in bash). Start new lines at logical boundaries.
Lead-out
"Clean, multi-line input makes everything better. And if you want to go even faster, the next video covers Vim mode—keyboard shortcuts that let you edit long prompts like a pro, without ever touching the mouse."
Reference URLs
Prep Reading
- Bash escaping rules (backslash, quotes, variables)
- Code block formatting best practices
- How Claude handles whitespace and indentation
- Common formatting gotchas (pasting from web, screenshots, etc.)
Notes for Daniel: Contrast the cramped one-liner with the clean multi-line version—make the difference obvious visually. When pasting code, use real examples that are messy (comments, long lines, weird formatting) so viewers see the value. Move briskly through the escaping section unless there's genuine confusion; most users won't need deep terminal escaping knowledge.