AI-Powered Coding: Learn Faster, Build Smarter

Haoyang Dong, Doctoral Student at UEF

Last updated: 18.09.2025

Why use inline AI for coding?

Inline AI is like a sharp pair of training wheels: it helps you move quickly without taking your hands off the handlebars.

Bottom line: AI is your co‑pilot, not your autopilot. You're still the engineer who decides what ships.

What you'll be able to do

Before you start

Tip: If the AI panel isn't visible, update your extensions, reload the window, and ensure you're signed in to the model provider.

Colab (Gemini): Generate, Explain, Transform

Goal: Create a simple plot and understand the code.

  1. Prompt the AI. In a new cell, open the Gemini prompt and ask:
    "Create a Matplotlib line plot of sin(x) from 0 to 10 with labeled axes and a title."
    See the inline suggestion in Figure 1, p.3. Click Accept to insert or Accept & Run to insert and execute.

  2. Read and run safely. Skim imports and outputs. Confirm libraries (numpy, matplotlib) exist; if not, add a pip install cell.

  3. Ask for an explanation. Highlight the generated cell → open the AI menu → Explain code (shown in Figure 2). You'll get a clear breakdown of each line.

  4. Transform when needed. Use Transform code to, for example, "switch to plotly," "vectorize this loop," or "add a legend and grid." (Figure 2).

  5. Iterate. Ask for small changes ("make the figure 8×4", "add a dashed line for cos(x)"), then re‑run.

Safety check: Prefer Accept over Accept & Run until you've read the code. Trust, but verify.

image-20250918012257831 image-20250918012437627

VS Code: Inline AI in Notebooks and Files

Goal: Use inline AI without leaving your editor.

  1. Open your file or notebook. In VS Code, open the .ipynb or .py.

  2. Start generation. Click Generate on the toolbar (see Figure 3, p.5). A blue prompt bar appears in the editor.

  3. Pick a model. Use the dropdown to choose a provider (e.g., GPT‑4.x, Claude Sonnet, Gemini). See Figure 4, p.6. Choose the strongest model you have for reasoning; switch to a faster one for quick drafts.

  4. Prompt in context. Type a request like:
    "Write a NumPy + Matplotlib example that plots sin(x) and labels axes; keep it under 15 lines with comments."
    The AI will propose code inline above your cell or selection (see Figure 5, p.7). Use Accept to insert or Accept & Run to run immediately.

  5. Review output. Run the cell; your chart should render as shown in Figure 6, p.8. If something fails, ask: "Fix the NameError; keep your edits minimal and explain."

  6. Explain / Refactor. Select code → prompt: "Explain each line in one sentence." or "Refactor to functions with type hints and docstrings."

image-20250918012936350

image-20250918013041321

image-20250918013150678

image-20250918013331011

Prompt recipes that work (copy/paste)


Best practices (and a few hard truths)

Do this

Avoid this

Common pitfalls & quick fixes

Ethics & integrity

Troubleshooting (fast)

Final words

Be fearless about asking and iterating. The fastest way to learn is to try, read, tweak, run, repeat. If the AI says something odd, push back with: "Show citations," "Use official API," or "Explain your choice." You're the reviewer. Ship only what you understand.