How to quickly delete the entire method? #374
-
like this title, I want to find a way that can quickly delete the entire method. But I didn't find it in the end. Can anyone tell me? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 11 replies
-
You can create some clever vim mapping to do this.
or even better
|
Beta Was this translation helpful? Give feedback.
-
This is my solution: |
Beta Was this translation helpful? Give feedback.
-
I have added a small modification to the mappings that allows to copy, delete or change methods (whole or just body) from any position of the method body or declaration:
You can find my complete .ideavim config file here |
Beta Was this translation helpful? Give feedback.
-
Wow, somehow I missed that we have access to Intellij commands in ex, the, at is a game changer for me! Thanks for sharing the solutions above. I wrote my own variations, which are more general but with the trade-off of Those don't rely on curly braces so work for more languages and contexts, instead using the vim-standard
Until today I was using the indent text objects provided by michaeljsmith/vim-indent-object (still a good workaround for those |
Beta Was this translation helpful? Give feedback.
You can create some clever vim mapping to do this.
e.g. if you place your caret at the first line of function definition
nnoremap dm Va{%d
would do the job for functions like this:or even better
nnoremap dk V/{<CR>%d
would also work for functions where arguments occupy multiple lines: