Hello, I’m trying to make a plugin for the first time, but I’ve hit a roadblock right away. I’m trying to make a simple plugin to fold all anonymous functions in a Javascript file.
For example I want:
var sum = function (a, b) { return a + b; };
to become:
var sum = function (a, b) { [...] };
But how do I select the function body?
So far I was trying something like
import sublime, sublime_plugin
class FoldCommand(sublime_plugin.TextCommand): def run(self, edit): regions = self.view.find_by_selector('entity.name.function.js') self.view.fold(regions)
But this actually folds the word “function”. How do I get the region insid the function body?