Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

% does not jump between def and end, etc (matchit...) #1885

Open
suan opened this issue Jun 29, 2017 · 10 comments
Open

% does not jump between def and end, etc (matchit...) #1885

suan opened this issue Jun 29, 2017 · 10 comments
Milestone

Comments

@suan
Copy link

suan commented Jun 29, 2017

  • Click thumbs-up 👍 on this issue if you want it!
  • Click confused 😕 on this issue if not having it makes VSCodeVim unusable.

The VSCodeVim team prioritizes issues based on reaction count.


The % key works as expected for single-character block identifiers such as (/), but NOT for multi-char ones such as def/end - such behavior is a staple for being productive in languages like Ruby.

I believe the matchit script/macro provides such functionality for actual Vim - more specifically https://github.com/vim-scripts/ruby-matchit.

There's actually the same reported issue over at vscode-ruby but I'm also creating it here as this might be the more appropriate place to solve the problem...

@haolly
Copy link

haolly commented Jun 29, 2017

@Chillee
Copy link
Member

Chillee commented Jun 29, 2017

@suan If there's a vscode extension, you'd be able to bind % to that command. Otherwise, you should be able to use the ruby-matchit plugin when/if this PR lands.

#1840

@kylesnowschwartz
Copy link

Does anyone have a concise workaround to implement this functionality while we wait?

current I'm using [ or ] while in command mode to move between method definition code blocks, but it relies on having spaces between blocks, and doesn't work for single line blocks.

@J-Fields
Copy link
Member

J-Fields commented Dec 4, 2020

As requested in #5805, supporting C/C++'s #if/#endif would be nice

@J-Fields J-Fields added this to the Backlog milestone Mar 5, 2021
@brandoncc
Copy link
Contributor

I hope this comes eventually!

@technicalpickles
Copy link

There is https://marketplace.visualstudio.com/items?itemName=redguardtoo.matchit for jumping between parens. It doesn't seem to work well for end and whatnot.

I've tried adding a normal mode key binding for it, but that doesn't seem to work:

CleanShot 2021-09-17 at 16 11 17

    "vim.normalModeKeyBindings": [
    
        {
            "before": ["%"],
            "commands": "bookmarks.list"
        }
    ],

@J-Fields J-Fields changed the title '%' does not jump between 'def' and 'end', etc (matchit...) % does not jump between def and end, etc (matchit...) Oct 15, 2021
@suan
Copy link
Author

suan commented Dec 30, 2021

Revisiting this as seems like #1840 was closed

Anyone found a way to make this work?

@andrewplummer
Copy link

I would love to see this as well. I'm using the matchit extension and a key mappings, however it has issues in Visual* modes, as vscode-vim seems to keep internal state of the selection. It might have to be implemented in vscode-vim itself...

@redguardtoo
Copy link

https://github.com/redguardtoo/vscode-matchit 2.0.0 is released. It add a new algorithm. So it's easier to support customized tags in any programming language.

See https://github.com/redguardtoo/vscode-matchit/blob/master/src/cpp.ts for the sample.

Pull requests are welcomed.

See https://github.com/redguardtoo/evil-matchit for regex samples.

@nxmndr
Copy link

nxmndr commented Nov 25, 2022

What would be really neat to have is the two possible matches for xml/html :

  • cursor on < => >
  • cursor on div => matching div

Somewhat subtle, but I think it's valuable.

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

No branches or pull requests

10 participants