I want to select (e.g. to comment/uncomment) entire functions at a time in neovim using the built-in LSP. I do this now by avoiding empty lines in functions so that I can vap to select the entire block, but this does not scale well to larger functions where spaces improve readability. I'd like for the editor to recognize and select entire functions.

How to use neovim to do this?

1 Answer 1


v]M should select until the end of function. It might be dependent on the language and the exact case if it works correctly.

Some plugins may implement this. Even some syntax files, I think. Another option is to rely upon ]= to select all lines that are of the same indentation.


implements it.

I also think vim-targets has vaF to select functions. Not sure about implementation. I don't think it is related directly to LSP, though I might be surprised.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.