VSCodeVim / VSCodeVim/Vim

Matching brace `%` skip comments and strings

Open
#3,207 2 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement
Dominant language
TypeScript
Stars
15.2k
Forks
1.5k
Avg merge
3d 18h
Merged PRs (30d)
6

Description

Feature request
Skip comments and strings when pressing % to jump to closing parenthesis or bracket comments are parsed.

The vim plugin matchit implements this behavior by default.

Sample
Assume sample code:

1 function run(line) {
2   console.log(
3     'This is the line:',
4     // line should be 1) a string and 2) longer that 5
5     typeof line == 'string' && line.length > 5 ? line : ''
6   );
7 }
  1. Put cursor at end of line 2, ...log(
  2. Press '%'
  3. Jumps to 1) on line 4. Expect it to jump to ); on line 6

The code is a bit contrived to show the example, but there are legitimate places where this occurs.

Desired behavior
Select code, not comments!

See also
#1885

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation file, test, or entry point is named. Start with the existing % matching behavior and compare it with the sample and Vim's matchit; done means comments and strings no longer affect matching, as described in the desired behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.