[mini.ai] How to grab entire lines when using function text object #1488
-
Contributing guidelines
Module(s)mini.ai QuestionBefore using mini.ai, I would copy or delete functions by going to visual line mode with shift-v and selecting the entire function, newlines included. I can then yank or delete the function. To paste, I go to the line I want the function to be moved to and then press P (or p if I want the function below the current line). This doesn't work when I use mini.ai's yaf or daf. I think it's because it doesn't yank the newlines at the end of the function. Is there a way to configure mini.ai to support this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Let's first settle on the use case: do you mean by "entire function" the "entire function call" (like The built-in function call is indeed a charwise textobject which means it won't include new lines (so as to have as narrow scope as possible). The function definition textobject can (and should) be implemented with the help of tree-sitter and it will include only the region that is provided by the respective tree-sitter query. Regardless of all of that, though, the previous workflow of "Shift-v followed by entire function" should still work with 'mini.ai' as it respect visual selection type (will keep linewise selection even if textobject is charwise, for example). If you want to do similar with operators directly, you can force particular mode by |
Beta Was this translation helpful? Give feedback.
Let's first settle on the use case: do you mean by "entire function" the "entire function call" (like
my_fun(1, 2)
) or "entire function definition" (likefunction my_fun(a, b) ... end
)? The first one is the one provided in 'mini.ai' by default, while the use case with new lines sounds like the second one.The built-in function call is indeed a charwise textobject which means it won't include new lines (so as to have as narrow scope as possible).
The function definition textobject can (and should) be implemented with the help of tree-sitter and it will include only the region that is provided by the respective tree-sitter query.
Regardless of all of that, though, the previous workflow of "…