zed icon indicating copy to clipboard operation
zed copied to clipboard

Add commands to select function, class, block, etc.

Open failable opened this issue 2 years ago • 2 comments

Check for existing issues

  • [X] Completed

Describe the feature

Originally from https://github.com/zed-industries/zed/discussions/6510

I know there are "editor::SelectLargerSyntaxNode" and "editor::SelectSmallerSyntaxNode" commands. Is currently selecting a function, class or a block (or even select region between current position and last position) directly supported now?

If applicable, add mockups / screenshots to help present your vision of the feature

No response

failable avatar Apr 20 '24 09:04 failable

I was under the impression that the paragraph actions were the ones to select blocks.

image

Moshyfawn avatar Apr 22 '24 12:04 Moshyfawn

@Moshyfawn Maybe. The idea here is to select the whole thing under current cursor by a single command. But it would also helpful to have commands like

  • move the start of function / method / class (we already have 'block' / 'paragraph')
  • move the end of function / method / class (we already have 'block' / 'paragraph')

failable avatar Apr 22 '24 13:04 failable

to revive this a bit, i think a few lsp powered ones would be:

editor::SelectNextFunction

visually selects the next function within the buffer

fn foo() {<caret>
    
}

fn bar() {
}

expected selection

fn bar() {
}

editor::SelectPreviousFunction

fn foo() {
    
}

fn bar() {<caret>
}

expected selection

fn foo() {
}

editor::SelectNextComment

```rs
fn foo() {<caret>
    
}

/// Some comment
fn bar() {
}

expected selection

/// Some comment

editor::SelectPreviousComment

same as SelectNextComment but in reverse

universalmind303 avatar Aug 26 '24 20:08 universalmind303