aziz / PlainTasks

An opinionated todo-list plugin for Sublime Text editor (version 2 and 3)
MIT License
3.29k stars 287 forks source link

[Feature request] Jump to next task #389

Closed CodingDive closed 9 months ago

CodingDive commented 5 years ago

Hey, first of all thank you for all the work on this package. It is by far my favorite todo list. It would be great to have a keybinding to jump to the next task. I write tons of comments between tasks and sometimes it takes a while to scroll to the next unresolved task. It has also happened that I would accidentally miss a task entirely while scrolling.

vovkkk commented 5 years ago

Do you know that there are fold to level commands? in main menu Edit → Code folding If your notes are indented under tasks it should be enough to overview all tasks and or go to a next one.

CodingDive commented 5 years ago

Thank you, I didn't know that. Since I'm not usually working with code folding in my tasks, I would still prefer a dedicated shortcut. I tried to create a sublime macro and just record ctrl + f ☐. But it seems that finding text is not supported in sublime macros.

vovkkk commented 5 years ago

Well, try to create command in Python then? You would get a list of all tasks and then use bisect to find the closest one to some point, well, cursor will be a point in this case, clear and re-add selection, scroll. All examples can be found in the file.

CodingDive commented 5 years ago

I've never used Python before but it might be a good place to start 😁 Thank you for the suggestion

CodingDive commented 9 months ago

Just coming back to this.

You can create a new plugin (tools => developer => new plugin)

import sublime
import sublime_plugin

class FindCheckboxCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.window().run_command('show_panel', {'panel': 'find', 'reverse': False})
        self.view.window().run_command('insert', {'characters': '☐'})
        self.view.window().run_command('find_next')
        self.view.window().run_command('hide_panel')
        if len(self.view.sel()) > 0:
            cursor_position = self.view.sel()[0].b
            self.view.sel().clear()
            self.view.sel().add(sublime.Region(cursor_position))

Save it to find_checkbox.py and you can bind it to the key of your choice (preferences: key bindings).

{ "keys": ["alt+n"], "command": "find_checkbox"}