Skip to content

Conversation

@Sdju
Copy link
Contributor

@Sdju Sdju commented Oct 29, 2025

Add line numbers for code blocks in Slidev VSCode extension

Motivation

I have many code blocks in my presentations. And I often need to know line numbers (e.g., for line highlighting {1|7-9...} ). It would therefore be useful to see line numbers directly in the editor.

Description

This PR adds an optional feature to display line numbers for code blocks in the Slidev VSCode extension, making it easier to reference specific lines when working with code in presentations.

Screenshots

image image

Changes

1. Line numbers decoration for code blocks

  • Added automatic line numbering for code blocks (triple backticks ```)
  • Ignores special blocks like magic-move (4+ backticks)
  • Added slidev.annotations-line-numbers setting (default: true)

Known issues

  1. Doesn't respect the startLine option
  2. Shares the same triggers for creating annotations — looks odd until the document is saved
image

@netlify
Copy link

netlify bot commented Oct 29, 2025

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit ec653bf
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/69035a8acb62760008d57bf2
😎 Deploy Preview https://deploy-preview-2320--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 29, 2025

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/client@2320

create-slidev

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev@2320

create-slidev-theme

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev-theme@2320

@slidev/parser

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/parser@2320

@slidev/cli

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/cli@2320

@slidev/types

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/types@2320

commit: ec653bf

@Sdju Sdju changed the title feat: show line numbers in markdown blocks [DRAFT] feat: show line numbers in markdown blocks Oct 29, 2025
@antfu antfu requested a review from kermanx October 30, 2025 05:39
@antfu
Copy link
Member

antfu commented Oct 30, 2025

Love the idea!

Copy link
Member

@kermanx kermanx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The lint error seems to require manual update. About the odd behavior when the document is not saved yet, I wasn't noticing this because I always have autoSave on🥲. Maybe it should be fixed somehow later.

@Sdju
Copy link
Contributor Author

Sdju commented Oct 30, 2025

The lint error seems to require manual update.

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants