سؤال

Java has curly braces that encapsulate the entire class definition. So when using the parenthsis ({ or }) key in vim, it goes to the end of the class instead of going to the next blank line or the end of the function definition. So how can I yank entire function and comment as well? In another word, I can I jump to next blank line regardless of the position?

هل كانت مفيدة؟

المحلول

I don't fully understand the problem, vim should match curly brackets, you can use shift-% to toggle your cursor position on matched brackets. With that said, if I understand you correctly(and trying it out myself) you are getting everything under the function header when you yank with ya{. Try this: on the end { of the function header, use ma to mark the position to register a, then % to move down to the end of the method, then y'a to yank it all. This will grab the entire function.

نصائح أخرى

You can yank the contents of a method while the cursor is in the method with yi{, in other words y ank i nner {

This is answer I came up with and I am not happy with it. In my vimrc, I set tab to be 4 whitespaces. So if I know that my function is separated by line that has 4 white spaces, I can do

y/^\s\s\s\s$
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top